Skip to content

peterm95018/ZeroWasteAPI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zero Waste API

Server Details

  • Express server, MSsql

  • Queries using Transact-SQL

  • Config details are located in .bash_profile

    config = {
      server: process.env.MSSQL_IP,
      user: process.env.MSSQL_USER,
      password: process.env.MSSQL_PASS,
      database: process.env.MSSQL_DATABASE
    };
    

API endpoints

http://zerowaste.ucsc.edu:3001/api/2017/spring
http://zerowaste.ucsc.edu:3001/api/2017/fall
http://zerowaste.ucsc.edu:3001/api/days/15
http://zerowaste.ucsc.edu:3001/api/days/30
http://zerowaste.ucsc.edu:3001/api/days/45
http://zerowaste.ucsc.edu:3001/api/days/60

Setting up the Server

  • Remote into the UCSC server
    ~/$ ssh [email protected]
    ~/$ password: ########
    ~/$ cd ZeroWasteAPI
  • Update the UCSC files with the latest master version
    ~/$ git pull
  • Find the running processes
    ~/$ ps aux | grep "node" or ~/$ ps aux | grep "node APIserver.js"
  • Kill the running processes
    kp ##### 4.8 0.7 69788 33280 pts/10 Sl May14 0:00 node APIserver.js
    ~/$ kill #####
  • Or do the last two in one step (careful because this will kill all processes with this name)
    ~/$ pkill -f "node APIserver.js"
  • Start Server by running (inclue 'nohup' and '&' so the server will run in the background)
    ~/$ nohup node APIserver.js &

Schema:

  [
   {
     PickupTime: "2017-08-09T00:13:00.000Z",
     Year_Month: "2017-08",
     Month_Num: 8,
     Week_Num: "2017-32",
     LoadmanAcct: 907,
     LoadName: "RR-CMK-OR",
     LoadName_Split: "RR-CMK-OR",
     Product: "Compost",
     Diversion_Type: "Diverted",
     ContainerType: "Roll Off",
     Size_CY: 20,
     Location: "Crown/Merrill Kitchen",
     Location_Type: "Dining",
     Load_Split: 12120
   },
   ...
 ]

Error response:

  {
    code: "EREQUEST",
    number: 2812,
    lineNumber: 1,
    state: 62,
    class: 16,
    serverName: "PP-PROD-DB-1",
    procName: "",
    originalError: {
      info: {
      number: 2812,
      state: 62,
      class: 16,
      message: "Could not find stored procedure 'S'.",
      serverName: "PP-PROD-DB-1",
      procName: "",
      lineNumber: 1,
      name: "ERROR",
      event: "errorMessage"
      }
    },
    name: "RequestError",
    precedingErrors: [ ]
  }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%