Skip to content

Commit

Permalink
feat(express): homepage and missing pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bartholomej committed Nov 22, 2024
1 parent 96b273b commit ab5d402
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import express from 'express';
import packageJson from './package.json';
import { csfd } from './src';
import { CSFDFilmTypes } from './src/interfaces/global';

const app = express();
const port = process.env.PORT || 3000;

app.get('/', (_, res) => {
res.json({
name: packageJson.name,
version: packageJson.version,
docs: packageJson.homepage,
links: ['/movie/:id', '/creator/:id', '/search/:query', '/user-ratings/:id']
});
});

app.get(['/movie/', '/creator/', '/search/', '/user-ratings/'], (req, res) => {
console.log(req.url);
res.json({ error: `ID is missing. Provide ID like this: ${req.url}${req.url.endsWith('/') ? '' : '/'}1234` });
});

app.get('/movie/:id', async (req, res) => {
try {
const movie = await csfd.movie(+req.params.id);
Expand Down

0 comments on commit ab5d402

Please sign in to comment.