Giter Club home page Giter Club logo

articleservice's Introduction

ArticleService

Example Article CRUD REST service using node and express.

Development server

Run node server for a dev server. Navigate to http://localhost:3000/.

Build

Run npm install to build the project.

ROUTES

POST /login
Login using username and password. Once authenticated you can access the secure routes by adding the security token returned by login under header key x-access-token.
HEADER:
content-type: application/json
BODY:
username (required)
password (required)
RESPONSE:
200 security token.
403 if wrong login credentials.
501 if system error. Contact administrator of service.

SECURE ROUTES

All requests need header key x-access-token

GET /users
DESCRIPTION:
Get all users.
HEADER:
x-access-token: security token returned by login
RESPONSE:
200 JSON array of user objects.
403 if invalid security token.
501 if system error. Contact administrator of service.

POST /users
DESCRIPTION:
Create user.
HEADER:
x-access-token: security token returned by login
content-type: application/json JSON:
username
password (required)
confirmPassword (required)
RESPONSE:
200 JSON of created user object.
403 if invalid security token.
501 if system error. Contact administrator of service.

PUT /users/id
DESCRIPTION:
Update user.
HEADER:
x-access-token: security token returned by login
content-type: application/json JSON:
username
password (required)
confirmPassword (required)
RESPONSE:
200 JSON of updated user objects.
403 if invalid security token.
404 if user not found.
501 if system error. Contact administrator of service.

DELETE /users/id
DESCRIPTION:
Delete user.
HEADER:
x-access-token: security token returned by login
content-type: application/json RESPONSE:
200 JSON of deleted user object.
403 if invalid security token.
404 if user not found.
501 if system error. Contact administrator of service.

GET /articles
DESCRIPTION:
Get articles.
HEADER:
x-access-token: security token returned by login
content-type: application/json RESPONSE:
200 JSON array of article objects.
403 if invalid security token.
501 if system error. Contact administrator of service.

POST /articles
DESCRIPTION:
Create article.
HEADER:
x-access-token: security token returned by login
content-type: application/json
JSON:
title
image
description
publishDate
modifyDate
RESPONSE:
200 JSON of created article object.
403 if invalid security token.
501 if system error. Contact administrator of service.

PUT /articles/id
DESCRIPTION:
Update article.
HEADER:
x-access-token: security token returned by login
content-type: application/json
JSON:
title
image
description
publishDate
modifyDate
RESPONSE:
200 JSON of updated user objects.
403 if invalid security token. 404 if article not found.
501 if system error. Contact administrator of service.

DELETE /articles/id
DESCRIPTION:
Delete article.
HEADER:
x-access-token: security token returned by login
content-type: application/json
RESPONSE:
200 JSON of deleted article objects.
403 if invalid security token. 404 if article not found.
501 if system error. Contact administrator of service.

POST /images
DESCRIPTION:
Accepts image file upload through form submission. Form attribute: action="/images" enctype="multipart/form-data" method="POST" type="file" name="filename".
HEADER:
x-access-token: security token returned by login
content-type: application/json
RESPONSE:
200 JSON of image metadata.

GET /images/id
DESCRIPTION:
Get image.
HEADER:
content-type: application/json
RESPONSE:
200 image

articleservice's People

Contributors

jaylagare 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.