bloominstituteoftechnology / web-sprint-challenge-build-a-web-api

2 stars 1.44k forks source link

Sprint Challenge Instructions

Tools

Project Set Up

Project Instructions

Introduction

You will build an API that has Create, Read, Update and Delete (CRUD) functionality for two resources called projects and actions.

Task 1: Build NPM Scripts

A "test" script already exists you can use to run tests against your code. A "resetdb" script exists that allows you to reset the database to its original state.

Task 2: Consume Environment Variables

Task 3: Build Endpoints

Inside api/projects/projects-router.js build the following endpoints:

Inside api/actions/actions-router.js build endpoints for performing CRUD operations on actions:

Task 4: Build Middleware functions

Information on Database Schemas

The description of the structure and extra information about each resource stored in the included database (./data/database.db3) is listed below.

Projects

Field Data Type Metadata
id number do not provide it when creating projects, the database will generate it
name string required
description string required
completed boolean not required, defaults to false when creating projects

Actions

Field Data Type Metadata
id number do not provide it when creating actions, the database will generate it
project_id number required, must be the id of an existing project
description string required, up to 128 characters long
notes string required, no size limit. Used to record additional notes or requirements to complete the action
completed boolean not required, defaults to false when creating actions

Information on Database Persistence Helpers

The project includes models you can use to manage the persistence of project and action data. These files are api/projects/projects-model.js and api/actions/actions-model.js. Both files publish the following api, which you can use to store, modify and retrieve each resource:

All these helper methods return a promise. Remember to use .then().catch() or async/await.

The projects-model.js includes an extra method called getProjectActions() that takes a project id as its only argument and returns a list of all the actions for the project.

We have provided test data for all the resources.

Important Notes: