-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ubclaunchpad/backend-endpoints
- Loading branch information
Showing
18 changed files
with
253 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,14 @@ | ||
import js from '@eslint/js' | ||
import jest from 'eslint-plugin-jest' | ||
import globals from 'globals' | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
|
||
/** @type {import('eslint').Linter.Config[]} */ | ||
export default [ | ||
{ ignores: ['dist'] }, | ||
{ | ||
files: ['**/*.{js,ts}'], | ||
languageOptions: { | ||
ecmaVersion: 'latest', | ||
globals: globals.node, | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
ecmaFeatures: { jsx: true }, | ||
sourceType: 'module', | ||
}, | ||
}, | ||
rules: { | ||
...js.configs.recommended.rules, | ||
}, | ||
}, | ||
{ | ||
files: ['**/__tests__/**/*.test.{js,ts}'], | ||
plugins: { | ||
jest, | ||
}, | ||
languageOptions: { | ||
globals: jest.environments.globals.globals | ||
}, | ||
rules: { | ||
...jest.configs.recommended.rules, | ||
} | ||
} | ||
] | ||
{ languageOptions: { globals: { ...globals.node, ...globals.jest } } }, | ||
pluginJs.configs.recommended, | ||
{ | ||
rules: { | ||
camelcase: ["warn", { properties: "never", ignoreDestructuring: false }], | ||
"max-len": ["warn", { code: 140 }], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import express from "express"; | ||
import auth from "../middlewares/auth.js"; | ||
import { createLogbook, getUserLogbooks, getLogbook, createLog, getLogbookLogs, getLog } from "../services/logbooks-service.js"; | ||
|
||
const router = express.Router(); | ||
|
||
router.post("", auth, async (req, res) => { | ||
const logbook = await createLogbook(req); | ||
if (logbook.error) { | ||
res.status(500).json({ error: logbook.error }); | ||
} else { | ||
res.status(201).json({ data: logbook }); | ||
} | ||
}); | ||
|
||
router.get("", auth, async (req, res) => { | ||
const userLogbooks = await getUserLogbooks(req); | ||
if (userLogbooks.error) { | ||
res.status(500).json({ error: userLogbooks.error }); | ||
} else { | ||
res.status(200).json({ data: userLogbooks }); | ||
} | ||
}); | ||
|
||
router.get("/:logbookID", auth, async (req, res) => { | ||
const logbook = await getLogbook(req); | ||
if (logbook.error) { | ||
res.status(500).json({ error: logbook.error }); | ||
} else { | ||
res.status(200).json({ data: logbook }); | ||
} | ||
}); | ||
|
||
router.post("/:logbookID/logs", auth, async (req, res) => { | ||
const log = await createLog(req); | ||
if (log.error) { | ||
res.status(500).json({ error: log.error }); | ||
} else { | ||
res.status(201).json({ data: log }); | ||
} | ||
}); | ||
|
||
router.get("/:logbookID/logs", auth, async (req, res) => { | ||
const logbookLogs = await getLogbookLogs(req); | ||
if (logbookLogs.error) { | ||
res.status(500).json({ error: logbookLogs.error }); | ||
} else { | ||
res.status(200).json({ data: logbookLogs }); | ||
} | ||
}); | ||
|
||
router.get("/:logbookID/logs/:logID", auth, async (req, res) => { | ||
const log = await getLog(req); | ||
if (log.error) { | ||
res.status(500).json({ error: log.error }); | ||
} else { | ||
res.status(200).json({ data: log }); | ||
} | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test("empty test", () => { | ||
expect(true).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test("empty test", () => { | ||
expect(true).toBe(true); | ||
}); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.