A ready to use rest API structure made with Express.js and Typescript.
Quick Express counts with:
- ORM (TypeORM)
- Tests (Jest and Super Test)
- API Documentation (apidoc)
- JWT Authentication
- A request parameters (request.body, request.query, request.params) validation system (that uses validate.js)
- A great and organized project structure.
You will need a .env
file. In this file, you put all your sensitive and environment info.
Running the command npm run generate env sqlite
, a .env
file will be generated using the requested template (sqlite, mysql or postgres).
Note¹: sqlite, mysql and postgres are just the supported templates by the CLI for now, but you can use any database that is supported by TypeORM
Note²: if you prefer, you can just make a copy of .env.example
and name it as .env
Is recommended to not commit the .env
file.
- Your modules (routes and endpoints) in
src/modules/
- Your middleware in
src/middleware/
- Your db models in
src/models/
The project already comes with a module called users
. It provides secure authentication for your project using JWT.
POST /users - Create a new user
POST /users/login - Login with email and password
POST /users/refresh - Get new access and refresh tokens
And the project also comes with a module called 'tasks', that shows you the appropriate way to make a good REST API. These endpoints only work with authenticated users.
GET /tasks - Retrieves all logged user tasks
GET /tasks/1 - Retrieves a specific task by id
POST /tasks - Creates a new task
PATCH /tasks/1 - Updates task #1
DELETE /tasks/1 - Deletes task #1
You can see all the default endpoints that comes with Quick Express in the requests.http
file, and you can use REST Client to test it all in VSCode.
The project also comes with a simple CLI tool to generate components such as Models and Modules, take a try:
npm run generate module nameOfMyModule
npm run generate model nameOfMyModel
npm run generate middleware nameOfMyMiddleware
npm run generate env sqlite
npm run generate env mysql
npm run generate env postgres
Quick Express comes with apidoc. Run npm run doc
to generate de doc on /doc
folder.
Consider consulting the apidoc documentation to learn more.
npm install
npm start