Giter Club home page Giter Club logo

rest-api-practice's Introduction

Kan Academy

We need to create a RESTful API for a school system. There will be teachers, students, and classes.

You will be using MongoDB and the Mongoose ODM for data persistence, and express with NodeJS to create an http web server.

First, Install MongoDB. Once installed, run the command mongod to start a local mongoDB server.

General Advice

It's highly advised to install POSTMAN to test your routes as you build it out.

Here's how one reasonable way to approach creating an API:

  1. Scaffold the app structure so that every route in the basic requirements is responding with a default response
  2. Create your mongoose models to get your data models to match your schema.
  3. Work on one route at a time according to the requirements below.
  4. Rinse and repeat

Basic Requirements

Create a RESTful API that adheres to the below documentation:

  • Teachers
{GET} /api/teachers
Lists information for every teacher
  Response
    success : BOOLEAN
    err     : STRING
    teachers: ARRAY<teacher: {
      name : STRING
      email: STRING
    }>
{GET} /api/teachers/:name
Lists the information about one teacher
  Response
    name : STRING
    email: STRING
{POST} /api/teachers
Creates a teacher
  Expected Body
    name : STRING
    email: STRING
  Response
    success: BOOLEAN
    err    : STRING
  • Students
{GET} /api/students
Lists information for every student
  Response
    success : BOOLEAN
    err     : STRING
    students: ARRAY<student: {
      name : STRING
      email: STRING
    }>
{GET} /api/students/:name
Lists information for one student
  Response
    success: BOOLEAN
    id     : INTEGER
    name   : STRING
    email  : STRING
    err    : STRING
{POST} /api/students
Creates a student
  Expected Body
    name : STRING
    email: STRING
  Response
    success: BOOLEAN
    err    : STRING
  • classes
{GET} /api/classes
Lists information for all classes
  Response
    success: BOOLEAN
    err    : STRING
    classes: ARRAY<class: {
      id  : INTEGER
      code: STRING
      name: STRING
    }>
{GET} /api/classes/:code
Lists information for one class
  Response
    success: BOOLEAN
    code   : STRING
    name   : STRING
    err    : STRING
{POST} /api/classes
Creates a class (codes must be unique)
  Expected Body
    code: STRING
    name: STRING
  Response
    success: BOOLEAN
    err    : STRING

Other Requirements

  • Modify the {POST} /api/students route to create classroom associations when a student is created.

Note: Because we are working with MongoDB–a noSQL database–we have the option of storing an array of associated information on the students model itself.

Mongoose may have some helper utility to create associations for you. Time to look at the docs!

{POST} /api/students
Creates a student
  Expected Body
    name   : STRING
    email  : STRING
    classes: ARRAY<classCodes: STRING>
  Response
    success: BOOLEAN
    id     : INTEGER
    err    : STRING
  • Create a route for associating an existing student with a set of classes
{PUT} /api/students/:name/editClasses
Updates a student's classes
  Expected Body
    classes: ARRAY<classCodes: STRING>
  Response
    success: BOOLEAN
    id     : INTEGER
    err    : STRING

Final Requirement

Render the information using a front-end framework of your choice.

  • Create a view component to render all students
  • Create a view component to render all teachers
  • Create a view component to render all classes
  • Create a view component with a form to create a teacher & students.

Extra Credit

  • Implement client-side routing with a library appropriate for your front-end framework. Don't render all the components at once, but swap the components depending on the browser's URL address.
  • Add form validation
  • Add styling to your app

rest-api-practice's People

Contributors

obber avatar

Watchers

James Cloos 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.