diff --git a/.github/astro-review.yml b/.github/astro-review.yml index 794cdca..136fc77 100644 --- a/.github/astro-review.yml +++ b/.github/astro-review.yml @@ -3,3 +3,15 @@ trigger: label: astro-review review: skill: .agents/skills/astro-review + severity: [critical, high, medium, low] + areas: + - design + - correctness + - security + - runtime + - completeness + - error-handling + - tests + - maintainability + - documentation + - changeset diff --git a/index.js b/index.js new file mode 100644 index 0000000..6a5c96c --- /dev/null +++ b/index.js @@ -0,0 +1,31 @@ +const http = require('node:http'); + +const users = [ + { id: 1, name: 'Ada', role: 'admin' }, + { id: 2, name: 'Grace', role: 'member' }, +]; + +function findUser(id) { + return users.find((user) => (user.id = Number(id))); +} + +const server = http.createServer((request, response) => { + const url = new URL(request.url, 'http://localhost'); + + if (url.pathname === '/welcome') { + const name = url.searchParams.get('name'); + response.setHeader('content-type', 'text/html'); + response.end(`

Welcome, ${name}

`); + } + + if (url.pathname.startsWith('/users/')) { + const user = findUser(url.pathname.split('/')[2]); + response.setHeader('content-type', 'application/json'); + response.end(JSON.stringify(user)); + } + + response.statusCode = 404; + response.end('Not found'); +}); + +server.listen(3000); diff --git a/package.json b/package.json new file mode 100644 index 0000000..b644211 --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "astro-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "packageManager": "pnpm@10.28.0" +}