Coder Social home page Coder Social logo

node-ts-api's Introduction

Node-TS API Template.

Purpose.

  • A simple Typescript API written in Node that can be used as a starter in multiple API application usecase scenarios. We will be using:
  1. Express - For API SetUp
  2. TypeORM - For our PostgreSQL ORM interfacing with our app.
  3. Docker Compose - To spin up our PostgreSQL and pgAdmin4 containers.

SetUp.

npm init

npm i -S express
npm install -D typescript @types/express

tsc --init
  • Setup package.json with your start scripts in dev env.
npm install -D ts-node-dev

* Dev environment running and watching script.
"dev": "node_modules/.bin/ts-node-dev --respawn --notify false --prefer-ts --ignore-watch node_modules -- src/app.ts "
  • SetUp TypeOrm.
npm install -S typeorm reflect-metadata pg

npm install -D @types/node

** ormconfig.json

  • This file contains metadata information needed by TypeORM before running the application. It contains database configuration information, and credentials, logging, entity and migration information.

Running the application.

  • Before running the app, ensure the containers are up and running, in order for you to create the node_sample DB over pgAdmin4 interface.
docker-compose up
  • In order to login to the pgAdmin4 console, use the credentials provided in the docker-compose pgadmin container environment configs, to login and check your IP Address(on Linux using ip a), before proceeding as you will use this as a HostName to create a connection between pgAdmin4 container and PostgreSQL Container.

  • After creating node_sample database or the database name in the ormconfig.json, start your application by running:

npm run dev

node-ts-api's People

Contributors

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