Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

ct-core

1.3.23 • Public • Published

CT-CORE

Build the REST API with json metadata.

This is a quick back-end system. You need create more modules, more versions, more APIs.. with only one json metadata

Table of contents

Requirements

Getting started

Install CT-CORE

npm install -g ct-core
Initial application
ct-core init
npm install
Updating application
ct-core update
npm install
Configuration environment
cp .env.copy .env
Start MongoDB
mongod --port 27017
Start application
ct-core start

Now go to homepage http://localhost:3000

Use Postman to test application

Some results for test

HTTP/1.1 200 OK

[
  {
    "gender": "male",
    "_id": "5e7115bd926d13129e9b1cdf",
    "username": "username7",
    "email": "email7@email.com",
    "password": "ssss",
    "age": 65,
    "phone": "0979737908",
    "birthday": "2020-03-17T07:06:16.664Z",
    "salary": 1500.8,
    "avatar": "https://i.pinimg.com/originals/90/b0/b3/90b0b3b15ccecf9efda592b0bdf462aa.jpg",
    "last_ip": "30.230.33.25"
  }
]

Also when doing requests, it's good to know that:

  • If you make POST, PUT, PATCH or DELETE requests, changes will be automatically.
  • Your request body JSON should be object enclosed, just like the GET output. (for example {"name": "Foobar"})
  • Id values are not mutable. Any id value in the body of your PUT or PATCH request will be ignored. Only a value set in a POST request will be respected, but only if not already taken.
  • A POST, PUT or PATCH request should include a Content-Type: application/json header to use the JSON in the request body. Otherwise it will result in a 200 OK but without changes being made to the data.

Routes

1	⇢ GET	⇢ /*/auth/get-token
2	⇢ PUT	⇢ /*/auth/refresh-token
3	⇢ GET	⇢ /*/system/get-captcha
4	⇢ PUT	⇢ /*/system/check-captcha
5	⇢ PUT	⇢ /v1/user/login
6	⇢ PUT	⇢ /v1/user/change-password
7	⇢ POST	⇢ /v1/user/new-user
8	⇢ GET	⇢ /v1/user/get-by-id/:id
9	⇢ GET	⇢ /v1/user/user-learning/:age_min/:age_max/:skip/:limit
10	⇢ GET	⇢ /v1/user/get-all
11	⇢ DELETE	⇢ /v1/user/delete-user
12	⇢ DELETE	⇢ /v1/user/delete-users

Database

api/v1/database/mongo.json

{
  "driver": "mongoose",
  "connection": "mongodb://{HOST}:{PORT}/{DATABASE}",
  "options": {
    "useCreateIndex": true,
    "useNewUrlParser": true,
    "useUnifiedTopology": true,
    "serverSelectionTimeoutMS": 5000
  }
}

CLI usage

1. ct-core init
2. ct-core update
3. ct-core start [options]

Options:
  --port, -p     Start app with port
  --host, -h     Start app with host
  --quiet, -q    Start app without log                                 [boolean]
  --help         Show help                                             [boolean]
  --version, -v  Show version number                                   [boolean]

Examples:
  ct-core init
  ct-core update
  ct-core start -h localhost -p 3000

https://www.npmjs.com/package/ct-core
Deployment

Install software to serve

npm install -g pm2
pm2 startup

Go to root application, copy the process.json

cp process.json.copy process.json
pm2 start process.json
pm2 save

License

MIT

Install

npm i ct-core

DownloadsWeekly Downloads

7

Version

1.3.23

License

MIT

Unpacked Size

115 kB

Total Files

55

Homepage

ct-eco.com

Last publish

Collaborators

  • avatar