Coder Social home page Coder Social logo

reesy / ts-express-tdd-mongodb-template Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 120 KB

A template backend typescript project using REST with express and supertest for TDD, and mongodb for a database.

License: MIT License

TypeScript 98.85% Shell 1.15%

ts-express-tdd-mongodb-template's Introduction

ts-express-tdd-mongodb-template

A back-end typescript template project using REST with express and supertest for TDD. It has CI/CD support through Jenkins and Docker.

This example just inserts, removes and reads a user and their associated email address from mongo and returns it in the REST API.

This project comes preset for vscode, the included .vscode/launch.json allows for running of the app with debugging as well as running of mocha tests with debugging.

The program has a configuration class that will try to read properties from a .env file, specifically

MONGO_ROOT_USER = ****
MONGO_ROOT_PASSWORD = ****
MONGO_PORT = 27017
MONGO_HOST = localhost

Any of these settings set in the environment will take precedence over a .env file entry

Cloning:

Through CLI:

git clone https://github.com/Reesy/ts-express-tdd-mongodb-template

Graphically (this will also generate a project on your profile)

image

Commands:

Install: (requires node and npm) npm install

Build: npm run build

Start: npm run start

Test: npm run test

Spinng up a mongo instance (requires docker and docker-compose installed): docker-compose up

Any tests added to the test folder will automatically be tested.

Requests

POST /api/v1/user

Example request:

POST /api/v1/user HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-Length: xy

{
    "name": "John Doe",
    "email": "[email protected]"
}

Example response:

HTTP/1.1 200 OK
Server: My RESTful API
Content-Type: application/json; charset=utf-8
Content-Length: xy

"Added user John Doe to the database" 

GET /api/v1/users

Eample request:

GET /api/v1/users HTTP/1.1

Example response:

HTTP/1.1 200 OK
Server: My RESTful API
Content-Type: application/json; charset=utf-8
Content-Length: xy

[
  {
    "name": "John Doe",
    "email": "[email protected]"
  },
  {
    "name": "Tim Smith",
    "email": "[email protected]"
]

Todo:

  • Create
  • Read
  • Wire up removable/delete to the API

ts-express-tdd-mongodb-template's People

Contributors

reesy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.