better embeds
This commit is contained in:
parent
729a7b8c56
commit
6ef218055e
3 changed files with 28 additions and 5 deletions
|
@ -7,13 +7,26 @@ import { randomBytes } from 'node:crypto';
|
|||
|
||||
let db = await initDb();
|
||||
|
||||
const mimes = {
|
||||
'image/gif': 'gif',
|
||||
'image/jpeg': 'jpg',
|
||||
'text/plain': 'txt',
|
||||
'application/json': 'json',
|
||||
'video/mp4': 'mp4',
|
||||
'video/webm': 'webm',
|
||||
'image/png': 'png',
|
||||
'audio/mpeg': 'mp3',
|
||||
'audio/wav': 'wav',
|
||||
};
|
||||
|
||||
const upload = multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
cb(null, './uploads/')
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
const uniqueSuffix = randomBytes(8).toString('hex');
|
||||
cb(null, uniqueSuffix + '.png')
|
||||
const type = mimes[file.mimetype] || 'txt';
|
||||
cb(null, uniqueSuffix + '.' + type)
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -81,7 +94,7 @@ function initr(req, res, next) {
|
|||
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
|
||||
{ link: '/users/' + (res.auth ? res.auth.username : ''), icon: '/login.svg', name: 'You' },
|
||||
{ link: '/you/messages', icon: '/mail.svg', name: 'Messages' },
|
||||
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' }
|
||||
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' }
|
||||
];
|
||||
|
||||
if (!res.auth || !res.auth.valid) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue