Coder Social home page Coder Social logo

okmttdhr / express-rest-api-2018 Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 83 KB

Boilerplate/Starter Project for building RESTful API using Node.js, Express and Sequelize.

License: MIT License

JavaScript 99.88% Shell 0.12%
express nodejs boilerplate starter-kit ecmascript2015 ecmascript2017 ecmascript2018 rest-api docker sequelize

express-rest-api-2018's Introduction

Express Rest API 2018

Boilerplate/Starter Project for building RESTful API using Node.js, Express and Sequelize.

(Influenced by express-rest-es2017-boilerplate).

Features

Pre Requirements

Getting Started

$ git clone https://github.com/okmttdhr/express-rest-api-2018.git
$ cd express-resr-api-2018
$ cp .env.sample .env
$ yarn docker:build
$ yarn docker:dev

Now your app is running.

$ curl -X POST -H 'Content-Type:application/json' -d '{"title": "ttttt", "body": "bbbbb"}' http://localhost/posts
{"message":"OK","id":1}
$ curl -H 'Content-Type:application/json' -X GET http://localhost/posts
{"posts":[{"id":1,"title":"ttttt","body":"bbbbb","created_at":"2018-06-09T00:43:21.000Z","updated_at":"2018-06-09T00:43:21.000Z"}],"total_count":1,"current_page":1,"total_page":1}

Testing

Run migration if you haven't yet.

$ docker exec -it expressrestapi2018_app_1 /bin/bash
root@id:/app# NODE_ENV=test yarn db db:migrate

All the test's command here.

$ docker exec -it expressrestapi2018_app_1 /bin/bash
# all the tests
root:/app# yarn test
# all the unit tests
root:/app# yarn test:unit
# only target file's test
root:/app# yarn test:unit:target ./path/to/file.js
# only target file's test with Node debugging client
root:/app# yarn test:unit:target debug ./path/to/file.js
# linting
root:/app# yarn test:lint
# flow
root:/app# yarn flow

Database

Connect to MySQL

$ docker exec -it expressrestapi2018_db_1 /bin/bash
root@id:/\# mysql -u root -pdocker
mysql> show databases;
+-----------------------------------+
| Database                          |
+-----------------------------------+
| information_schema                |
| express_rest_api_2018_development |
| express_rest_api_2018_test        |
| mysql                             |
| performance_schema                |
+-----------------------------------+
4 rows in set (0.00 sec)

Creating Model and Migration

License

MIT

express-rest-api-2018's People

Contributors

okmttdhr avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

paulkagiri

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.