Coder Social home page Coder Social logo

phoneapi's Introduction

Express Server API

This is a simple API for educational purposes

Create a database with Mlab

  • Create an account in mlab.com
  • In your dashboard you will see MongoDB Deployments click the button create new
  • select the cloud provider that you want and select single-node and sandbox plan and name it

step1

Once your database is created we need to create the users.

  • Select the tab users and create an user for that database

step2

In order to connect using the driver you need to copy the address similar to this one. mongodb://<dbuser>:<dbpassword>@ds1516621.mlab.com:51661/phoneapi

Modify dbuser and dbpassword with the user that you have created.

Install and Configuration

Before start you need to rename .env.sample to .env and modify the env variable called DATABASE with your database.

NODE_ENV=development
DATABASE=mongodb://localhost:27017/<DBname>

In terminal run npm install in order to install all the dependencies. Once all the dependencies are installed type npm start.

Now you server is running in http://localhost:3000.

$ npm install
$ npm start

Routes

URL HTTP verb Request body Action
/api/phones GET (empty) Returns all the phones
/api/phones POST JSON Add a new phone
/api/phones/:id GET (empty) Returns the specified phone
/api/phones/:id PUT JSON Edits the specified phone
/api/phones/:id DELETE (empty) Deletes the specified phone

Phone Model

The phone model has the following structure that you will pass into the body

{
  "brand": "Nokia",
  "name": "3310",
  "image": "http://placekitten.com/200/300",
  "specs": [
    "barato",
    "bonito",
    "vintage"
  ]
}

phoneapi's People

Contributors

zapatran avatar

Watchers

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