Skip to content

marcoshuck/typescript-express-firestore

Repository files navigation

TypeScript + Express + Firestore

An API REST created with Typescript and using Express and Firestore modules

Features

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.

Getting started

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

Before start working on code

yarn install or npm install

Building

npm run build Gets the ./build directory with js files.

Source code analysis

npm run lint Uses lint to analyze the source code.

Starting the application

npm run start Runs the application in a node instance.

Watch mode (build)

npm run build-watch Compiles the application every time some change has been made.

Watch mode (start)

npm run start-watch Runs the application every time some change has been made. Should be run in parallel with Build watch mode.

Documentation

npm run doc Generates the project's documentation using typedoc.

API Endpoint

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.

Test

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.

Project structure

|   .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

ToDo

  • JWT

Releases

No releases published

Packages

No packages published