This commit is contained in:
Pitu 2021-06-20 03:53:38 +09:00
parent ff80ea8431
commit bc5ca732b0
9 changed files with 8955 additions and 60 deletions

21
babel.config.js Normal file
View File

@ -0,0 +1,21 @@
function isBabelLoader(caller) {
return caller && caller.name === 'babel-loader';
}
module.exports = api => {
if (api.env('test') && !api.caller(isBabelLoader)) {
return {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
]
]
};
}
return {};
};

9
jest.config.js Normal file
View File

@ -0,0 +1,9 @@
module.exports = {
moduleFileExtensions: ['js', 'json', 'vue'],
moduleDirectories: ['node_modules'],
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
},
transformIgnorePatterns: ['/node_modules/(?!vue)']
};

8933
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -84,6 +84,7 @@
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@nuxt/types": "2.15.7",
"@types/bcryptjs": "^2.4.2",
"@types/cors": "^2.8.10",
"@types/cron": "^1.7.2",
@ -95,10 +96,12 @@
"@types/sharp": "^0.27.1",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@vue/test-utils": "^1.2.1",
"autoprefixer": "^9.4.7",
"axios": "^0.21.1",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^27.0.2",
"cpy-cli": "^3.1.1",
"cross-env": "^7.0.3",
"eslint": "^7.24.0",
@ -106,6 +109,8 @@
"eslint-config-marine": "^9.0.6",
"eslint-import-resolver-nuxt": "^1.0.1",
"eslint-plugin-vue": "^5.2.1",
"jest": "^27.0.4",
"jest-serializer-vue": "^2.0.2",
"node-sass": "^6.0.0",
"nodemon": "^2.0.7",
"postcss-css-variables": "^0.11.0",
@ -113,12 +118,29 @@
"prisma": "^2.21.2",
"sass-loader": "^12.1.0",
"ts-node": "^9.1.1",
"typescript": "^4.2.2"
"typescript": "^4.2.2",
"vue-jest": "^3.0.7"
},
"eslintConfig": {
"extends": [
"marine/node"
]
"marine/node",
"marine/vue"
],
"parserOptions": {
"parser": "babel-eslint",
"sourceType": "module"
},
"settings": {
"import/resolver": {
"nuxt": {
"nuxtSrcDir": "./src/site",
"extensions": [
".js",
".vue"
]
}
}
}
},
"prisma": {
"schema": "src/prisma/schema.prisma"

View File

@ -7,7 +7,8 @@ import rfs from 'rotating-file-stream';
import rateLimit from 'express-rate-limit';
import jetpack from 'fs-jetpack';
import cron from 'cron';
// import { loadNuxt, build } from 'nuxt';
// @ts-ignore - nuxt types can't be found - https://github.com/nuxt/nuxt.js/issues/7651
import { loadNuxt, build } from 'nuxt';
import Routes from './structures/routes';
@ -66,19 +67,13 @@ const start = async () => {
// Serve the uploads
server.use(express.static(path.join(__dirname, '../../../uploads')));
// void serveNuxt();
const isProd = process.env.NODE_ENV === 'production';
const nuxt = await loadNuxt(isProd ? 'start' : 'dev');
server.use(nuxt.render);
if (!isProd) build(nuxt);
// TODO: move into the database config. (we can just show the crontab line for start, later on we can add dropdowns and stuff)
new cron.CronJob('0 0 * * * *', Util.saveStatsToDb, null, true);
};
/*
const serveNuxt = async () => {
const isProd = process.env.NODE_ENV === 'production';
const nuxt = await loadNuxt(isProd ? 'start' : 'dev');
server.use(nuxt.render);
if (!isProd) build(nuxt);
};
*/
void start();

View File

@ -10,7 +10,11 @@
"lib": ["esnext", "dom"],
"rootDir": "./",
"outDir": "./dist",
"sourceRoot": "./"
"sourceRoot": "./",
"types": [
"@types/node",
"@nuxt/types"
]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "../api/main.ts", "../api/structures/routes.ts", "../api/structures/interfaces.ts"]
}

View File

@ -72,6 +72,7 @@ async function start() {
const keys = Object.keys(defaultSettings);
for (const item of keys) {
// @ts-ignore no idea
envfile += `${item}=${defaultSettings[item]}\n`;
}
jetpack.write('.env', envfile);

0
types/index.d.ts vendored Normal file
View File