An open API service indexing awesome lists of open source software.

https://github.com/marcoshuck/typescript-express-firestore

An API REST created with Typescript, using Express and Firestore modules
https://github.com/marcoshuck/typescript-express-firestore

api express firebase firestore nodejs rest typescript

Last synced: about 21 hours ago
JSON representation

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

Awesome Lists containing this project

README

        

# TypeScript + Express + Firestore
An API REST created with Typescript and using Express and Firestore modules

[![](https://travis-ci.org/marcoshuck/typescript-express-firestore.svg?branch=master)](https://travis-ci.org/marcoshuck/typescript-express-firestore) [![](https://david-dm.org/marcoshuck/typescript-express-firestore.svg)](https://david-dm.org/marcoshuck/typescript-express-firestore) ![](https://img.shields.io/github/forks/marcoshuck/typescript-express-firestore.svg) ![](https://img.shields.io/github/stars/marcoshuck/typescript-express-firestore.svg) ![](https://img.shields.io/github/license/marcoshuck/typescript-express-firestore.svg) ![](https://img.shields.io/github/issues/marcoshuck/typescript-express-firestore.svg)

## 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](https://firebase.google.com/docs/admin/setup?authuser=0). This file is required in [db.ts](https://github.com/marcoshuck/typescript-express-firestore/blob/master/src/db.ts#L3)

### 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](https://github.com/marcoshuck/typescript-express-firestore/blob/master/src/routes/index.ts#L7) 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](https://github.com/marcoshuck/typescript-express-firestore/blob/master/src/controllers/example.controller.ts) 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