mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2026-02-28 19:30:03 +00:00
First commit: /a/, /gallery/, images, gifv
This commit is contained in:
74
src/index.ts
Normal file
74
src/index.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
import Hapi = require('@hapi/hapi');
|
||||
import Path = require('path');
|
||||
import { handleAlbum, handleGallery, handleMedia, handleTag, handleUser } from './handlers';
|
||||
|
||||
import CONFIG from './config';
|
||||
|
||||
const init = async () => {
|
||||
const server = Hapi.server({
|
||||
port: CONFIG.port,
|
||||
host: CONFIG.host,
|
||||
address: CONFIG.address,
|
||||
routes: {
|
||||
files: {
|
||||
relativeTo: Path.join(__dirname, 'static')
|
||||
}
|
||||
}
|
||||
});
|
||||
await server.register(require('@hapi/vision'));
|
||||
await server.register(require('@hapi/inert'));
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/css/{param*}',
|
||||
handler: ({
|
||||
directory: {
|
||||
path: Path.join(__dirname, 'static/css')
|
||||
}
|
||||
} as any)
|
||||
});
|
||||
server.views({
|
||||
engines: {
|
||||
pug: require('pug')
|
||||
},
|
||||
relativeTo: __dirname,
|
||||
path: 'templates',
|
||||
});
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/{baseName}.{extension}',
|
||||
handler: handleMedia,
|
||||
});
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/a/{albumID?}',
|
||||
handler: handleAlbum,
|
||||
});
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/t/{tagID?}',
|
||||
handler: handleTag,
|
||||
});
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/user/{userID?}',
|
||||
handler: handleUser,
|
||||
});
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/gallery/{galleryID}',
|
||||
handler: handleGallery,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
console.log('Server running on %s', server.info.uri);
|
||||
};
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
init();
|
||||
Reference in New Issue
Block a user