Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
schedules-legacy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
schedules-legacy
Commits
3436ebcb
Commit
3436ebcb
authored
Dec 24, 2016
by
Mark Stenglein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added initial api
- It's connected to the database!!
parent
0dfa592f
Pipeline
#690
failed with stage
in 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
16 deletions
+37
-16
routes/api/v1.js
routes/api/v1.js
+37
-16
No files found.
routes/api/v1.js
View file @
3436ebcb
...
...
@@ -13,34 +13,55 @@ var express = require('express')
var
router
=
express
.
Router
()
// var Semester = require('../../models/Semester')
var
ical
=
require
(
'
ical-generator
'
)
// var db = require('models')
var
config
=
require
(
'
config
'
)
// Load site wide configurations
var
schoolSlugs
=
config
.
get
(
'
schoolSlugs
'
)
var
db
=
require
(
'
models
'
)
// ////////////////////////////////////////////////////////////////////////////
// JSON API Section
// Get school and semester slug listing
// JSON API Section Get school and semester slug listing
router
.
get
(
'
/json/schools
'
,
function
(
req
,
res
,
next
)
{
res
.
json
(
schoolSlugs
)
db
.
University
.
findAll
({
attributes
:
[
'
slug
'
,
'
name
'
,
'
website
'
]
}).
then
(
function
(
query
)
{
var
schools
res
.
json
(
query
)
})
})
// GET semester slug listing for school
router
.
get
(
'
/json/semesters/:SCHOOLSLUG
'
,
function
(
req
,
res
,
next
)
{
db
.
Semester
.
findAll
({
attributes
:
[
'
slug
'
,
'
name
'
],
where
:
{
university
:
req
.
params
[
'
SCHOOLSLUG
'
]
}
}).
then
(
function
(
query
)
{
res
.
json
(
query
)
})
})
// GET classes for a semester
router
.
get
(
'
/json/classes/:SEMSLUG
'
,
function
(
req
,
res
,
next
)
{
// var slug = req.params['SEMSLUG']
// find each person with matching slug
// remove unwanted fields from request
// excecute the request (caches with redis)
// if there was an error or nothing was returned
// send an error message
db
.
Section
.
findAll
({
where
:
{
semester
:
req
.
params
[
'
SEMSLUG
'
]
}
}).
then
(
function
(
query
)
{
res
.
json
(
query
)
})
})
// else send out the semester object as json
// GET Class information for one course by CRN
router
.
get
(
'
/json/classes/crn/:CRN
'
,
function
(
req
,
res
,
next
)
{
db
.
Section
.
findAll
({
where
:
{
crn
:
req
.
params
[
'
CRN
'
]
}
}).
then
(
function
(
query
)
{
res
.
json
(
query
)
})
})
// ////////////////////////////////////////////////////////////////////////////
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment