Giter Club home page Giter Club logo

new-node-service-template's Introduction

New Service Template

A template for creating new templates.

Table of contents

Introduction

Project structure

Below is a quick outline of the structure of the app:

.
├── api                        # API endpoints
|   ├── some-endpoint
|   |   |   ├── controller.ts  # Calls the service methods and handles responses
|   |   |   ├── router.ts      # Sets up the router and all the available routes
|   |   |   └── service.ts     # Handles the more granular parts; DB actions, remote requests etc.
|   │   └── ...
├── constants                  # Constants to use throughout the service
│   └── ...
├── errors                     # Error classes and helpers
│   └── ...
├── middlewares                # Custom Express middlewares
│   └── ...
├── models                     # ORM-odels
│   └── ...
├── modules                    # Modules are used to separate code to make it more testable
|   ├── some-module
|   |   ├── doesSomethingCool.ts
|   |   ├── index.ts
|   │   └── ...
│   └── ...
├── types                      # TypeScript types & interfaces
│   └── ...
├── utils                      # Utility functions
│   └── ...
├── index.ts                   # Entrypoint - starts the server
└── server.ts                  # This is where the Express app is setup and configured

Development

1. Prerequisites

2. Setup

  1. Install the dependencies:
yarn install

3. Running locally

  1. Simply run:
yarn start
  1. You can check the API is running using the following cURL command:
curl -X GET http://localhost:${PORT}/healthcheck

Testing

1. Running tests

  1. Simply run the command:
yarn test

This will build and run a Postgres docker image and run the tests against it.

Deployment

1. Building the image

When building the Docker image, we want to inject env vars at build time, as the Dockerfile injects the build args as env vars into the container.

docker build \
-t kieranroneill/new_service_template \
--build-arg log_level=error \
--build-arg node_env=production \
--build-arg port=3000 \
--build-arg service_name=new-service-template \
--build-arg version=1.0.0 \
.

2. Running the image

docker run \
--name new_service_template \
-it \
-p 1337:${PORT} \
kieranroneill/new_service_template:latest

new-node-service-template's People

Contributors

semantic-release-bot avatar

Watchers

James Cloos avatar Kieran O'Neill 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.