Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(experimental): kick off inventory project #808

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

06kellyjac
Copy link
Contributor

Track projects and their licenses
Docker compose configuration for dev with logging tracing and metrics (mostly done)
CRUD for mongo

Track projects and their licenses
Docker compose configuration for dev with logging tracing and metrics (mostly done)
CRUD for mongo
Copy link

netlify bot commented Nov 27, 2024

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 8e6fae1
🔍 Latest deploy log https://app.netlify.com/sites/endearing-brigadeiros-63f9d0/deploys/6746f71873840200081e2cbe

Comment on lines +13 to +35
router.post('/create', async (req, res) => {
const { error, data } = await createSchema.safeParseAsync(req);
if (error) {
req.log.error(error);
res.status(500).json({ error: 'invalid format' }).end();
return;
}
const { body: submittedLicense } = data;
if (submittedLicense.spdxID) {
const spdxMatch = await License.findOne({ spdxID: data.body.spdxID }).exec();
// already exists
if (spdxMatch !== null) {
res.status(500).json({ error: 'license with SPDX ID already exists' }).end();
return;
}
}
const _id = uuidv4();
await License.create({
_id,
...submittedLicense,
});
res.status(200).json({ created: _id }).end();
});

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.
Comment on lines +41 to +53
router.get('/read/:id', async (req, res) => {
const { error, data } = await readSchema.safeParseAsync(req);
if (error) {
req.log.error(error);
res.status(500).json({ error: 'invalid format' }).end();
return;
}
const {
params: { id },
} = data;
const license = await License.findOne({ _id: id }).lean().exec();
res.status(200).json({ license }).end();
});

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.
Comment on lines +60 to +74
router.patch('/update/:id', async (req, res) => {
const { error, data } = await updateSchema.safeParseAsync(req);
if (error) {
req.log.error(error);
res.status(500).json({ error: 'invalid format' }).end();
return;
}
const {
body: updateLicense,
params: { id },
} = data;
await License.findOneAndUpdate({ _id: id }, updateLicense);
res.setHeader('Content-Location', `/api/v0/licenses/read/{id}`);
res.status(204).json({ status: 'ok' }).end();
});

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.
Comment on lines +80 to +92
router.post('/delete/:id', async (req, res) => {
const { error, data } = await deleteSchema.safeParseAsync(req);
if (error) {
req.log.error(error);
res.status(500).json({ error: 'invalid format' }).end();
return;
}
const {
params: { id },
} = data;
await License.deleteOne({ _id: id }).exec();
res.status(204).json({ status: 'ok' }).end();
});

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.
Comment on lines +95 to +100
router.get('/list', async (req, res) => {
req.log.info('root');
// lean forces raw objects, not UUID buffers
const result = await License.find().lean(true).exec();
res.status(200).json(result).end();
});

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.11%. Comparing base (50ccb18) to head (8e6fae1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #808   +/-   ##
=======================================
  Coverage   63.11%   63.11%           
=======================================
  Files          47       47           
  Lines        1681     1681           
=======================================
  Hits         1061     1061           
  Misses        620      620           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant