Skip to content

TheoSoko/Z-API

Repository files navigation

About

This is a RESTful web API built for interfacing with the Zemus mobile application.

The product has two main aspects:

  • A social media platform
  • A tool to search for news from the entire world.

The environment mainly consists of Node, TypeScript, Hapi, Knex.

This project is the main building block of the Zemus backend application, and is deployed on a cloud instance, running on Debian.

We are currently building a solution for crawling, indexing and storing web content (news articles), based on ElasticSearch.

Tech Stack

Language : TypeScript

Runtime : Node.js

HTTP framework : Hapi

Authentication : Hapi/jwt

SQL query builder : Knex.js

Process manager (production) : PM2

Running the server

Install dependencies

  npm install

Locally

Start the server with npm script

  npm run build

The transpilation to JS before the project builds and runs happens "under the hood", thanks to nodemon and ts-node.

On server

  npm run prod-js

API reference

Entry point :

  • URL: http://api.zemus.info
  • IPv4: 162.19.92.192
  • Port: 8080

Endpoints :

On all endpoints except mentionned :

  • Response header - Accept: application/json, application/x-www-form-urlencoded
  • Request header - Authorization: bearer *actual token*
  • All query or body parameter followed by a "?" are optionnal

Auth :

  • POST /sign-in
  • HEAD | GET /auth
    • query: ?id=7
    • headers: Authorization: bearer * actual token *

Search :

  • GET /search
    • query:
      - ?q=football
      - &country=FR
      - &src=journals,
    • no auth needed

Users :

  • GET /users/{id}
  • DELETE /users/{id}
  • POST /users
    • payload:
      - {firstname, lastname, email, password, country}
  • PATCH /users/{id}
    • payload:
      - {firstname, lastname, email, password, country}

Friends :

  • GET /users/{id}/friends
  • DELETE /users/{id}/friends/{id}
  • PUT /users/{id}/friends/{id}
  • GET /users/{id}/friends/{id}

Favorites :

  • GET /users/{id}/favorites
  • GET /favorites/{id}
  • DELETE /favorites/{id}
  • POST /users/{id}/favorites
    • payload:
      - {title, link, image?, country, publication_date, description}

Reviews :

  • GET /users/{id}/reviews
  • GET /reviews/{id}
  • DELETE /reviews/{id}
  • POST /users/{id}/reviews
    • payload:
      - {theme, presentation, image?, visibility_id}
  • PATCH /reviews/{id}
    • payload:
      - {theme?, presentation?, image?, visibility_id?}
  • POST /reviews/{id}/articles
    • Accept: application/json
    • payload:
      - Array of [ FavoriteId: (int) OR {title, link, image?, country?, description?, publication_date} ]
  • POST /users/{id}/reviews/articles
    • Accept: application/json
    • payload:
      • {theme, presentation, image?, visibility_id, articles}
      • articles: Array of [ FavoriteId: (int) OR {title, link, image?, country?, description?, publication_date} ]
  • DELETE /reviews/{id}/articles

Feed :

  • GET /users/{id}/feed
    • query: ?page=1

Images :

  • GET /users/{id}/profile-picture
  • PUT /users/{id}/profile-picture
    • Accept: image/jpeg, image/png, image/gif
    • payload:
      • some binary image

Infos pratiques

Le projet est situé dans /srv/zemus-api sur le serveur.

Le process lié au service est relancé au démarrage du serveur, grâce à PM2.

Pour transpiler le projet dans build (en prod) : tsc --project tsconfig.production.json

About

A RESTful web API for a social media mobile app

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published