An API REST created with Typescript and using Express and Firestore modules
This project has or uses the following features:
- Typescript.
- Express.
- Google Firestore.
- Linting
- Model - View - Controller pattern.
- SOLID principles.
- Class validation.
- CI/CD with Travis.
- Tests with mocha and chai.
- Autogenerated documentation with typedoc.
This application was created using NodeJS, you can look at the package.json file for more information about what packages have been used.
You need to create a keys folder in the application root directory, and inside of it, you should move the .json file provided by Google Firestore. Read more information about this: Google Firestore SDK documentation. This file is required in db.ts
yarn install
or npm install
npm run build
Gets the ./build directory with js files.
npm run lint
Uses lint to analyze the source code.
npm run start
Runs the application in a node instance.
npm run build-watch
Compiles the application every time some change has been made.
npm run start-watch
Runs the application every time some change has been made. Should be run in parallel with Build watch mode.
npm run doc
Generates the project's documentation using typedoc.
In this application there is only one endpoint available, it's the examples endpoint. You can check how any route works reading its specific controller class. For further information about the examples route, you can read the ExampleController class.
The firestore test is related to my own firestore database. You can play around with the source file to understand mocha and chai modules. Be sure to check and change the id argument in both read and update methods.
| .env.example
| .gitignore
| .travis.yml
| LICENSE
| package.json
| README.md
| tsconfig.json
| tslint.json
| yarn.lock
|
+---src
| | app.ts
| | db.ts
| | env.ts
| | index.ts
| |
| +---controllers
| | | controller.ts
| | | example.controller.ts
| | |
| | \---interfaces
| | controller.interface.ts
| |
| +---middleware
| | error.middleware.ts
| |
| +---models
| | | example.model.ts
| | |
| | \---interfaces
| | example.interface.ts
| |
| +---repositories
| | | firestore.repository.ts
| | |
| | \---interfaces
| | firestore.interface.ts
| |
| +---routes
| | example.routes.ts
| | index.ts
| |
| \---utils
| error.interface.ts
|
+---tests
| \---repositories
| firestore.test.ts
|
\---views
error.pug
- JWT