GithubHelp home page GithubHelp logo

gabrieldonnantuoni / news-provider-jd Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 434 KB

News provider RESTFUL API with Express, Typescript and Objection.js made as a challenge of JungleDevs selective process.

TypeScript 99.28% Shell 0.72%

news-provider-jd's Introduction

News Provider RESTFUL API with Node.js, Typescript, PostgreSQL and Objection.js

Description

This project was built on a stage of JungleDevs selective process, where the original repo can be found here

Challenge goal: The purpose of this challenge is to give an overall understanding of a backend application. You’ll be implementing a simplified version of news provider API.

  • REST architecture;
  • Authentication and permissions;
  • Data modeling and migrations;
  • SQL database;
  • Query optimization;
  • Serialization;
  • Production builds.

Acceptance criteria

  • Clear instructions on how to run the application in development mode
  • Clear instructions on how to create production builds
  • A good API documentation or collection
  • Models created using Objection.js
  • Login API: /api/login
  • Sign-up API: /api/sign-up
  • Administrator restricted APIs:
    • CRUD /api/admin/authors
    • CRUD /api/admin/articles
  • List article endpoint /api/articles?category=:slug with the following response:
[
  {
    "author": {
      "name": "Author Name",
      "picture": "https://picture.url"
    },
    "category": "Category",
    "title": "Article title",
    "summary": "This is a summary of the article"
  },
  ...
]
  • Article detail endpoint /api/articles/:id with different responses for anonymous and logged users:

    Anonymous

    {
      "author": {
        "name": "Author Name",
        "picture": "https://picture.url"
      },
      "category": "Category",
      "title": "Article title",
      "summary": "This is a summary of the article",
      "firstParagraph": "<p>This is the first paragraph of this article</p>"
    }

    Logged user

    {
      "author": {
        "name": "Author Name",
        "picture": "https://picture.url"
      },
      "category": "Category",
      "title": "Article title",
      "summary": "This is a summary of the article",
      "firstParagraph": "<p>This is the first paragraph of this article</p>",
      "body": "<div><p>Second paragraph</p><p>Third paragraph</p></div>"
    }

Install dependencies

  • With npm: npm install
  • With yarn: yarn

Initial configuration

Rename the .env.example file to .env and fill it with your data.

Instructions to Run

  • Database: docker-compose up will start the PostgreSQL DB
  • yarn db:reset will initiate or restart the db configured with .env variables. Add NODE_ENV=enviromentOfChoice before command to run in that enviroment.
  • yarn dev is configured to start the server/index.ts using ts-node-dev
  • yarn build will build the next app and emit js files on dist directory
  • yarn start will start the app in production mode.

Live app

You can see this app running on heroku with AWS RDS here

To Do

  • Build an landing page on the path: /
  • Finish integration tests
  • Implement unit tests

Challenges and choices

Talking about the tools chosen to build this application, the language(Node.js), ORM and database were proposed by the task. In this context of backend, what is nice to emphasize is the solutions I built for validations of received data (req.body) and validation of Authentication, that could be required or just a privilege. Look for it in server/middlewares. Besides that I chose to use Typescript, a superset of Javascript that helps a lot with autocompletes when conding and with catching erros before running.

Now about frontend, I have the oportunity to choose everything. I setted a goal to build a landing page with real-time interaction with the API. I opted for React that is a UI lib that I have more proficiency with. On top of React, I added Next.js a framework that has built-in Server Side Rendering which helps with SEO. For help with styling I picked Material UI that is a easy to use UI library for React that has really nice features and helps to save a lot time.

news-provider-jd's People

Contributors

gabrieldonnantuoni avatar vjusto avatar dependabot[bot] avatar

Watchers

 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.