fix: public

This commit is contained in:
typicode
2024-01-26 17:29:44 +01:00
parent e58a6ac499
commit d0307026e4
3 changed files with 3 additions and 2 deletions

1
public/test.html Normal file
View File

@ -0,0 +1 @@
<!-- Testing automatic serving of files from the 'public/' directory -->

View File

@ -67,7 +67,7 @@ await test('createApp', async (t) => {
const arr: Test[] = [
// Static
{ method: 'GET', url: '/', statusCode: 200 },
{ method: 'GET', url: '/output.css', statusCode: 200 },
{ method: 'GET', url: '/test.html', statusCode: 200 },
{ method: 'GET', url: `/${file}`, statusCode: 200 },
// CORS

View File

@ -31,7 +31,7 @@ export function createApp(db: Low<Data>, options: AppOptions = {}) {
const app = new App()
// Static files
app.use(sirv(join(__dirname, '../public'), { dev: !isProduction }))
app.use(sirv('public', { dev: !isProduction }))
options.static
?.map((path) => (isAbsolute(path) ? path : join(process.cwd(), path)))
.forEach((dir) => app.use(sirv(dir, { dev: !isProduction })))