Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
node_modules
node_modules/
dist/
.env
.env.funder
*.pem
__pycache__/
*.log
.DS_Store
coverage/
.nyc_output/
24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"name": "auto-funder-express",
"name": "hero-api",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "vitest run",
"test:watch": "vitest"
},
"devDependencies": {
"vitest": "^0.34.0",
"supertest": "^6.3.3",
"@types/express": "^4.17.17",
"@types/supertest": "^2.0.12"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@_koii/create-task-cli": "^1.1.3-beta.1",
"axios": "^1.7.7",
"crypto": "^1.0.1",
"dotenv": "^16.4.5",
"express": "^4.21.0"
"express": "^4.18.2"
}
}
}
9 changes: 9 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import express from 'express';
import heroRoutes from './routes/heroRoutes';

const app = express();

// Use hero routes
app.use(heroRoutes);

export default app;
18 changes: 18 additions & 0 deletions src/routes/heroRoutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import express from 'express';

const router = express.Router();

const heroData = {
'spiderman': {
name: 'Spider-Man',
realName: 'Peter Parker',
powers: ['Wall-crawling', 'Spider-sense', 'Superhuman strength'],
firstAppearance: 'Amazing Fantasy #15'
}
};

router.get(['/spiderMan', '/spiderman', '/spider-man', '/SpiderMan'], (req, res) => {
res.json(heroData['spiderman']);
});

export default router;
37 changes: 37 additions & 0 deletions tests/spiderMan.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { describe, it, expect } from 'vitest';
import request from 'supertest';
import app from '../src/app'; // Adjust the path to your Express app

describe('Spider-Man Endpoint', () => {
it('should return correct Spider-Man information', async () => {
const response = await request(app)
.get('/spiderMan')
.expect('Content-Type', /json/)
.expect(200);

expect(response.body).toEqual({
name: 'Spider-Man',
realName: 'Peter Parker',
powers: ['Wall-crawling', 'Spider-sense', 'Superhuman strength'],
firstAppearance: 'Amazing Fantasy #15'
});
});

it('should handle case variations', async () => {
const variations = ['/spiderman', '/spider-man', '/SpiderMan'];

for (const path of variations) {
const response = await request(app)
.get(path)
.expect('Content-Type', /json/)
.expect(200);

expect(response.body).toEqual({
name: 'Spider-Man',
realName: 'Peter Parker',
powers: ['Wall-crawling', 'Spider-sense', 'Superhuman strength'],
firstAppearance: 'Amazing Fantasy #15'
});
}
});
});