/CSDataWebApi

For a Project in CS-452, This is the backend of the project written in NodeJS for handling REST Calls

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

CSDataWebApi Database System

Developed For My CS-452 Class Assigment for WebApi Calls

Node.js CI

Purpose

Allow for easy access and usage for a backend Server Written in NodeJS

Installation

NPM Version NPM Downloads

This uses a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.10 or higher is required.

Installation is done using the npm install command:

$ npm install express --save

Features

How dose the Api Work?

  1. Generate the following AUTH api for you at http://localhost:3000
Method URL data(if needed) server action(The Request is Successful)
GET /api/v1/Auth Lists The Api Structure and usage Calls
POST /api/v1/Auth/CreateAccount {name: ..., email: ..., password: ...} Checks inputs and creates new Account
POST /api/v1/Auth/Login {email: ..., password: ...} Checks username/passwords and Generates APi Token
GET /api/v1/Auth/TestToken {token(the generated Login token)} verifies token and displays test data
GET /api/v1/Data {token(the generated Login token)} verifies token and displays Users Data

(more details coming soon!!)

Calling The API!!

To use the API all you have to do is make an HTTP Call to the web address with the correct information Added

Example 1.) Calling in Powershell

Invoke-RestMethod -Uri http://localhost:3000/api/v1/Auth

Example 2.) Calling Basic Api Using HTTP:

http://localhost:3000/api/v1/Auth

Example 3.) Calling CreateAccount Using HTTP:

To add items to the request just append them to the url using HTTP Query

http://localhost:3000/api/v1/Auth/CreateAccount
?username=TestUsername         //First Value Gets a ?
&password=TestPassword         //Other Values Get a &
&email=TestEmail@captechu.edu  //Other Values Get a &

The Entire Example

http://localhost:3000/api/v1/Auth/CreateAccount?username=TestUsername&password=TestPassword&email=TestEmail@email.edu

The response Will look Like this

{
    "result":true,
     "data":{
        "username":"TestUsername",
        "password":"B3HJyF69ue3HvHOO9arYBA==$1FK3trdZWx8BYvfsl1hDn9Yciu4PwBGUiVxGKFRYGN//jArcRA501rQOdPJOuZrbeIKBP30bcMYbOYNe+vpHkw==",
        "email":"TestEmail@captechu.edu",
        "accounttype":"",
        "oauth2":{}
     }
}

TODOS

  • better http status code
  • better config params
  • docs
  • new features

license

MIT license

William Wright
wawright@captechu.edu