Git Product home page Git Product logo

node-express-api's Introduction

1- Express.js API Rest

It is a simple node application provided as Rest API. It can be used with docker or serverless.

2 - Tech

Uses a number of open source projects to work properly:

  • express.js
  • mysql
  • node.js - v16.x

3 - Development

You can use docker or serverless to start your new instance.

3.1 - Docker

You need to create a image local to run a aplication. I created 3 images, those represent stages like stable, development and production.

Create a stable( latest ) image tag:

docker build -t pedrotti/node:express .

Create a new production tag with updated source code inside:

docker build --no-cache -f Dockerfile.prod -t pedrotti/node-express:v1.0 .

Create a new developement tag using nodemon:

docker build --no-cache -f Dockerfile.dev -t pedrotti/node-express:dev .

That tag is already setted on docker-compose.yml.

Start a new instance at root project:

docker-compose up -d

Charge a new instance of database.

docker exec node-api npx sequelize --help
docker exec node-api npx sequelize db:migrate
docker exec node-api npx sequelize db:seed:all 

Watch logs from nodemon:

docker logs --follow node-api 

3.2 - Serverless

Install Serverless as global package.

npm install -g serverless

Install plugins to start localhost.

npm install serverless-offline --save-dev
npm install serverless-sequelize-migrations --save-dev

Startup a new instance.

serverless offline

3.2.1 - Database

Serverless will bind in port 3000 on localhost. You could create a new instance of database at localhost too. Install a mysql-server package or using docker mysql bind por 5306 to localhost.

Create a new instance with docker:

docker run -d --name mysql -p 5306:5306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7

Charge that instance with migrations:

serverless migrations list
serverless migrations up

4 - Deploy

4.1 - Docker

Todo: expand this topic.

4.2 - Serverless

If you are trying to use AWS Lambda, first you need to install AWS CLI and configure Access key ID and Secret acess key from a IAM account.

aws configure

Serverless deploy will translate serverless.yml configs into AWS CloudFormation commands.

serverless deploy

4.2.1 - Package

Todo: expand this topic.

4.2.2 - Layer

Todo: expand this topic.

5 - References

  • AWS CLI - AWS Command Line Interface
  • Serverless - Cloud computing execution model
  • Express.js - A back end web application framework for building RESTful APIs
  • Lambda Layers - Creating and sharing Lambda layers

node-express-api's People

Contributors

michaelpedrotti avatar

Watchers

 avatar Diego Tsuyoshi 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.