Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
/ file-api Public archive

HTTP API using the server’s filesystem as a database.

License

Notifications You must be signed in to change notification settings

jrpool/file-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

file-api

HTTP API using a server’s filesystem as a database.

Project Members

Jonathan Pool

modules

app.js

Discussion

General

This application demonstrates the use of a server’s filesystem as a database and the [express package][exp] to create, destroy, read, and modify the database in response to HTTP requests received by the server.

The demonstration takes the form of a quotation-list manager. You can use it to add a quotation to the list, remove a quotation from it, and replace a quotation with another other quotation.

The API receives and transmits data as JSON-compliant strings.

The application fulfills the requirements of the “RESTful Routing” module in Phase 2 of the Learners Guild curriculum, and specifically the “RESTful Routing Using Files” exercise in that module.

Installation and Setup

  1. These instructions presuppose that (1) npm and cURL are installed.

  2. Your copy of this project will be located in its own directory, inside some other directory that you may choose or create. For example, to create that parent directory inside your own home directory’s Documents subdirectory and call it projects, you can execute:

    mkdir ~/Documents/projects

Make that parent directory your working directory, by executing, for example:

`cd ~/Documents/projects`
  1. Clone this project’s repository into it, thereby creating the project directory, named file-api, by executing:

    git clone https://github.com/jrpool/file-api.git file-api

  2. Make the project directory your working directory by executing:

    cd file-api

  3. Install required dependencies (you can see them listed in package.json) by executing:

    npm i

Usage and Examples

To start the application, execute npm start (or, if under Windows, npm run startwin).

To create a quotation entry, execute (for example):

curl http://localhost:3000/api/quotes -d '{"quote": "I can’t lie.", "author": "George Washington"}'

To retrieve a quotation entry, execute (for example):

curl http://localhost:3000/api/quotes/1

To replace (e.g., to correct) a quotation entry, execute (for example):

curl --request PUT http://localhost:3000/api/quotes/1 -d '{"quote": "I cannot tell a lie.", "author": "George Washington"}'

To delete a quotation entry, execute (for example):

curl --request DELETE http://localhost:3000/api/quotes/1

To perform linting, execute npm run lint.

About

HTTP API using the server’s filesystem as a database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published