Merge branch 'master' into feature/typescript

This commit is contained in:
Pitu 2021-06-21 15:23:28 +09:00
commit 77db6f34c6
12 changed files with 59 additions and 44 deletions

View File

@ -17,4 +17,4 @@ COPY --from=ffmpeg /usr/local /usr/local
COPY . .
RUN mkdir uploads && mkdir database
CMD ["sh", "-c", "npm run migrate && npm run seed && npm run build && npm start"]
CMD ["sh", "-c", "npm run migrate && npm run seed && npm start"]

View File

@ -71,10 +71,21 @@ export default {
autoprefixer,
},
},
extend(config, { isDev }) {
// Extend only webpack config for client-bundle
if (isDev) {
config.devtool = 'source-map';
axios: {
baseURL: `${process.env.NODE_ENV === 'production' ? process.env.DOMAIN : 'http://localhost:5000'}/api`
},
build: {
extractCSS: process.env.NODE_ENV === 'production',
postcss: {
preset: {
autoprefixer
}
},
extend(config, { isDev }) {
// Extend only webpack config for client-bundle
if (isDev) {
config.devtool = 'source-map';
}
}
},
},

View File

@ -14,7 +14,6 @@
"dev": "nodemon src/api/structures/Server",
"migrate": "knex migrate:latest",
"seed": "knex seed:run",
"update": "git pull && npm install && npm run migrate && npm run build && npm run restart",
"restart": "pm2 restart chibisafe",
"overwrite-config": "cross-env OVERWRITE_SETTINGS=true",
"test:vue": "jest --testPathPattern=src/site",

View File

@ -17,7 +17,11 @@ class configGET extends Route {
albumLinkLength: Util.config.generatedAlbumLength,
chunkSize: Util.config.chunkSize,
publicMode: Util.config.publicMode,
userAccounts: Util.config.userAccounts
userAccounts: Util.config.userAccounts,
metaThemeColor: Util.config.metaThemeColor,
metaDescription: Util.config.metaDescription,
metaKeywords: Util.config.metaKeywords,
metaTwitterHandle: Util.metaTwitterHandle
}
});
}

View File

@ -3,7 +3,7 @@ const Util = require('../../utils/Util');
class tagDELETE extends Route {
constructor() {
super('/tag/:id/:purge*?', 'delete');
super('/tag/:id/:purge?', 'delete');
}
async run(req, res, db, user) {

View File

@ -76,8 +76,8 @@ class Server {
for (const File of routes) {
try {
const route = new File();
this.server[route.method](Util.config.routePrefix + route.path, route.authorize.bind(route));
log.info(`Found route ${route.method.toUpperCase()} ${Util.config.routePrefix}${route.path}`);
this.server[route.method](`/api${route.path}`, route.authorize.bind(route));
log.info(`Found route ${route.method.toUpperCase()} /api${route.path}`);
} catch (e) {
log.error(`Failed loading route from file ${routeFile} with error: ${e.message}`);
}

View File

@ -29,12 +29,13 @@ const schema = Joi.object({
.label('Service name')
.description('Name of the service'),
domain: Joi.string().default(`http://localhost:${env.SERVER_PORT}`)
secret: Joi.string().default(``)
.meta({
section: Sections.SERVICE
})
.label('Domain')
.description('Full domain this instance is gonna be running on'),
.label('Secret')
.description('64 char secret key to sign JWT sessions')
.note('If this setting is changed then every user session will be invalidates and every user will need to log in again.'),
// File related settings
chunkSize: Joi.number().integer().greater(0)
@ -60,7 +61,7 @@ const schema = Joi.object({
.label('Generate zips')
.description('Allows users to download entire albums in ZIP format'),
generatedFileNameLength: Joi.number().integer().min(6)
generatedFilenameLength: Joi.number().integer().min(6)
.default(12)
.meta({
section: Sections.FILE
@ -68,7 +69,7 @@ const schema = Joi.object({
.label('Generated file name length')
.description('How long should the automatically generated file name be'),
generatedAlbumLength: Joi.number().integer().min(6)
generatedAlbumLength: Joi.number().integer().min(4)
.default(6)
.meta({
section: Sections.FILE
@ -76,21 +77,6 @@ const schema = Joi.object({
.label('Generated album name length')
.description('How long should the automatically generated album identifier be'),
maxLinksPerAlbum: Joi.number().integer().greater(0)
.default(5)
.meta({
section: Sections.FILE
})
.label('Maximum album links')
.description('Maximum allowed number of a distinct links for an album'),
uploadsFolder: Joi.string().default('uploads')
.meta({
section: Sections.FILE
})
.label('Uploads folder')
.description('Name of the folder where the uploads will be stored'),
blockedExtensions: Joi.array()
.items(Joi.string().pattern(/^(\.\w+)+$/, { name: 'file extension' }))
.default(['.jar', '.exe', '.msi', '.com', '.bat', '.cmd', '.scr', '.ps1', '.sh'])
@ -108,7 +94,7 @@ const schema = Joi.object({
.label('Public mode')
.description('Allows people to upload files without an account'),
userAccount: Joi.boolean().default(true)
userAccounts: Joi.boolean().default(true)
.meta({
section: Sections.USERS
})
@ -132,7 +118,7 @@ const schema = Joi.object({
.label('Meta description')
.description('Short and accurate summary of the content of the page'),
metaKeyword: Joi.string().default('chibisafe,lolisafe,upload,uploader,file,vue,images,ssr,file uploader,free')
metaKeywords: Joi.string().default('chibisafe,lolisafe,upload,uploader,file,vue,images,ssr,file uploader,free')
.meta({
section: Sections.SOCIAL_AND_SHARING
})
@ -144,7 +130,7 @@ const schema = Joi.object({
section: Sections.SOCIAL_AND_SHARING
})
.label('Twitter handle')
.description('Your twitter handle'),
.description('Your twitter username'),
// Instance settings
backgroundImageURL: Joi.string().uri().default(p => `${p.domain}/assets/images/background.jpg`)

View File

@ -40,7 +40,7 @@ class Util {
static getEnvironmentDefaults() {
return {
domain: process.env.DOMAIN,
routePrefix: process.env.ROUTE_PREFIX || '/api',
routePrefix: '/api',
rateLimitWindow: process.env.RATE_LIMIT_WINDOW || 2,
rateLimitMax: process.env.RATE_LIMIT_MAX || 5,
secret: process.env.SECRET || randomstring.generate(64),
@ -59,7 +59,12 @@ class Util {
metaThemeColor: process.env.META_THEME_COLOR || '#20222b',
metaDescription: process.env.META_DESCRIPTION || 'Blazing fast file uploader and bunker written in node! 🚀',
metaKeywords: process.env.META_KEYWORDS || 'chibisafe,lolisafe,upload,uploader,file,vue,images,ssr,file uploader,free',
metaTwitterHandle: process.env.META_TWITTER_HANDLE || '@your-handle'
metaTwitterHandle: process.env.META_TWITTER_HANDLE || '@your-handle',
backgroundImageURL: process.env.BACKGROUND_IMAGE_URL || '',
logoURL: process.env.LOGO_URL || '',
statisticsCron: process.env.STATISTICS_CRON || '0 0 * * * *',
enabledStatistics: process.env.ENABLED_STATISTICS ? process.env.ENABLED_STATISTICS.split(',') : ['system', 'fileSystems', 'uploads', 'users', 'albums'],
savedStatistics: process.env.SAVED_STATISTICS ? process.env.SAVED_STATISTICS.split(',') : ['system', 'fileSystems', 'uploads', 'users', 'albums']
};
}

View File

@ -93,7 +93,7 @@
</button>
</div>
<div class="level-item">
<span class="has-text-default">{{ details.links.length }} / {{ config.maxLinksPerAlbum }} links created</span>
<span class="has-text-default">{{ details.links.length }} links created</span>
</div>
</div>
@ -151,9 +151,6 @@ export default {
computed: {
...mapState(['config', 'auth'])
},
mounted() {
console.log(this.isNsfw);
},
methods: {
...mapActions({
deleteAlbumAction: 'albums/deleteAlbum',

View File

@ -3,7 +3,7 @@
<div v-for="[key, field] in Object.entries(settings)" :key="key">
<b-field
:label="field.flags.label"
:message="getErrorMessage(key) || field.flags.description"
:message="getErrorMessage(key) || getMessage(field)"
:type="getValidationType(key)"
class="field"
horizontal>
@ -118,6 +118,13 @@ export default {
},
getValues() {
return this.values;
},
getMessage(field) {
let msg = field.flags.description;
if (field.notes?.length) {
msg += field.notes.map(note => `\n${note}`);
}
return msg;
}
}
};
@ -128,7 +135,8 @@ export default {
.field {
margin-bottom: 1em;
::v-deep .help.is-danger {
::v-deep .help {
font-size: 12px;
white-space: pre-line;
}
}

View File

@ -12,7 +12,7 @@
<hr>
<div v-for="[sectionName, fields] in Object.entries(sectionedSettings)" :key="sectionName" class="block">
<h5 class="title is-5 has-text-grey-lighter">
<h5 class="title is-5 has-text-grey-lighter text-center mb4 mt4">
{{ sectionName }}
</h5>
<JoiObject ref="jois" :settings="fields" :errors="validationErrors" />
@ -106,3 +106,8 @@ export default {
}
};
</script>
<style lang="scss" scoped>
h5.title {
text-decoration: underline;
}
</style>

View File

@ -153,7 +153,7 @@
class="album">
<div
class="arrow-container"
@click="promptDeleteTag">
@click="promptDeleteTag(tag.id)">
<i class="icon-arrow" />
</div>
<!--
@ -246,7 +246,7 @@ export default {
});
},
async deleteTag(id, purge) {
const response = await this.$axios.$delete(`tags/${id}/${purge ? 'purge' : ''}`);
const response = await this.$axios.$delete(`tag/${id}/${purge ? 'purge' : ''}`);
this.getTags();
return this.$buefy.toast.open(response.message);
},