Giter Site home page Giter Site logo

trainapi's Introduction

TrainAPI

Stack

How to run locally

  • System requirements: Node.js
  • Fork the repository
  • Clone it to your local repo
  • Run "npm install" to install dependencies
    • "body-parser": "^1.19.0",
    • "cors": "^2.8.5",
    • "dotenv": "^8.2.0",
    • "express": "^4.17.1",
    • "nodemon": "^2.0.4",
    • "pg": "^8.3.3"
  • Run "npm start" to run local server
  • See .env.sample for environment variables

Database (SQL Elephant)

Trains table:

id name length stopid maintenance
serial primary key varchar(250) integer(10) integer(10) - foreign key boolean

Stops table:

id city
serial primary key varchar(250)

Features

Endpoint Route
GET (all trains) ("/trains")
GET (specific train by id) ("/trains/:id
GET (all trains currently in maintenance) ("/trains/running
PUT (send train to specific station) ("/trains/sendtostation/:id
PUT (update specific train maintenance true/false) ("/trains/:id
GET (all stops) ("/stops")
GET (current stop for specific train) ("/stops/:id"

Structure

File Description
server.js Server and endpoints (!main file)
dbConfig.js Configuration of database (ElephantSQL)
trainsRoutes.js Configuration of trains routes
sopsRoutes.js Configuration of stops routes
trainsController.js Controllers for trains endpoints
stopsController.js Controllers for stops endpoints
logRequests.js Middleware for logfile
logRequests.txt Logfile for client requests (date, method, url, status, process duration)

Structure

tbd

Front-end

trainfrontend (default front-end react-app)

trainapi's People

Contributors

davidecravero avatar natascha2020 avatar simo54 avatar

Stargazers

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