Skip to content

Latest commit

 

History

History
 
 

web-api

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

API

Introduction

Hello, welcome onboard.

This project design on #oSoc18 is a little API to fetch data about STIB/MIVB stop and gathering useable/meaningfull data about them.

This document purpose is to give an orverview about this API part of the project and necessary steps before working on it.

Table of contents

Technologies

This API exploits the following technologies :

Name Description More infos
Node.JS v10.6 JavaScript runtime built on Chrome's V8 JavaScript engine Site web
ECMAScript 6 New features added or improved to ECMAScript standard. Better way to code in JS. Only used some of them Site web, Overview
ExpressJS v4.16.0 Fast, minimalist web framework for Node.JS Site web
Mongoose v5.1.0 Elegant MongoDB Object modeling for Node.JS Site web, MongoDB Driver

Installation

Requirements

  • All technologies, listed above, are necessary.
  • This project was build with Node.JS v10.6, your Node environment must set to at least this version. Follow the instructions
  • A connection to a MongoDB to store collections and documents.

Get Started

    # Grab the project on the repository
    $ git clone https://github.com/oSoc18/octotrails.git

    # Move to the directory
    $ cd octotrails

    # Install dependencies
    $ npm install --save

Configuration

The application need some configuration before running. By default, the config values as defined on this file. To overwrite those, please do so :

Rename the env.example to .env.

    # Copy and rename the .env.example
    $ copy .env.example .env

Open the .env file.

Jwt Secret

I strongly recommand to change your JWT_SECRET to some random string. Typically, this string should be at least 32 characters long.

If the JWT_SECRET key is not set, the default value will be used !

Database

All required info to make a sucessful connection to the database have to be input in the config with the corresponding key.

    MONGOOSE_DEBUG=(true|false)
    MONGO_HOST=
    MONGO_PORT=

On the first run, all required collections/documents will be created and fullfilled with some basic data.

STIB/MIVB API URL

An URL to get the STIB DATA about the stop must be provided, otherwise the stop resource will not be available.

    STIB_API = {URL to the data on the stop}

Run

    # Run localy at http://0.0.0.0:8081
    $ npm run start:server

    # Now, let's test that API
    # Open this URL in a browser : http://0.0.0.0:8081/api/zen

    # To run in production :
    # On the Nginx file for the site dedicated to this APi,
    # make sure to redirect to the folder public/index.php

Routes

Base url : /api

All routes must be prefixed with this base url.

For instance, to get all categories , you must hit this route : https://example.com/api/categories

Formats of objet send and return by this API

Endpoints

Test/Check endpoint

Auth

Stop Resource

Question Resource

History Resource

Category Resource

Enhancements