@design-edito/cli 0.0.77 → 0.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/assets/list.txt +1 -2
- package/cli/assets/version.txt +1 -1
- package/cli/index.js +2 -2
- package/cli/index.js.map +3 -3
- package/make-template/assets/express/esbuild.config.js +19 -0
- package/make-template/assets/express/package.json +16 -12
- package/make-template/assets/express/src/index.ts +14 -50
- package/make-template/assets/express/src/public/index.css +7 -0
- package/make-template/assets/express/src/public/index.html +15 -0
- package/make-template/assets/express/src/public/index.js +31 -0
- package/make-template/assets/express/src/tsconfig.json +7 -3
- package/make-template/assets/express/src/www/index.ts +42 -0
- package/make-template/assets/express-api/Dockerfile +18 -0
- package/make-template/assets/express-api/Dockerfile.dev +8 -0
- package/make-template/assets/express-api/env +36 -0
- package/make-template/assets/express-api/esbuild.config.js +26 -0
- package/make-template/assets/express-api/gitignore +214 -0
- package/make-template/assets/express-api/package.json +60 -0
- package/make-template/assets/express-api/src/api/auth/_utils/index.ts +47 -0
- package/make-template/assets/express-api/src/api/auth/index.ts +25 -0
- package/make-template/assets/express-api/src/api/auth/login/index.ts +101 -0
- package/make-template/assets/express-api/src/api/auth/logout/index.ts +45 -0
- package/make-template/assets/express-api/src/api/auth/refresh-token/index.ts +54 -0
- package/make-template/assets/express-api/src/api/auth/request-email-verification-token/index.ts +45 -0
- package/make-template/assets/express-api/src/api/auth/request-new-password/index.ts +62 -0
- package/make-template/assets/express-api/src/api/auth/signup/index.ts +99 -0
- package/make-template/assets/express-api/src/api/auth/submit-new-password/index.ts +61 -0
- package/make-template/assets/express-api/src/api/auth/verify-email/index.ts +79 -0
- package/make-template/assets/express-api/src/api/auth/whoami/index.ts +68 -0
- package/make-template/assets/express-api/src/api/index.ts +18 -0
- package/make-template/assets/express-api/src/api/types.ts +76 -0
- package/make-template/assets/express-api/src/api/utils.ts +146 -0
- package/make-template/assets/express-api/src/database/index.ts +173 -0
- package/make-template/assets/express-api/src/email/index.ts +47 -0
- package/make-template/assets/express-api/src/env/index.ts +77 -0
- package/make-template/assets/express-api/src/errors/index.ts +128 -0
- package/make-template/assets/express-api/src/index.ts +42 -0
- package/make-template/assets/express-api/src/init/index.ts +156 -0
- package/make-template/assets/express-api/src/jwt/index.ts +105 -0
- package/make-template/assets/express-api/src/public/index.css +7 -0
- package/make-template/assets/express-api/src/public/index.html +15 -0
- package/make-template/assets/express-api/src/public/index.js +31 -0
- package/make-template/assets/express-api/src/schema/_history/index.ts +124 -0
- package/make-template/assets/express-api/src/schema/_meta/index.ts +113 -0
- package/make-template/assets/express-api/src/schema/index.ts +17 -0
- package/make-template/assets/express-api/src/schema/user/index.ts +117 -0
- package/make-template/assets/express-api/src/schema/user-email-validation-token/index.ts +20 -0
- package/make-template/assets/express-api/src/schema/user-password-renewal-token/index.ts +20 -0
- package/make-template/assets/express-api/src/schema/user-revoked-auth-token/index.ts +26 -0
- package/make-template/assets/express-api/src/tsconfig.json +16 -0
- package/make-template/assets/express-api/src/www/index.ts +43 -0
- package/make-template/index.js +2 -3
- package/make-template/index.js.map +3 -3
- package/package.json +8 -9
- package/make-template/assets/express/src/routes/index.ts +0 -7
- package/upgrade/index.js +0 -12
- package/upgrade/index.js.map +0 -7
package/cli/assets/list.txt
CHANGED
package/cli/assets/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.79
|
package/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import m from"node:process";import{promises as l}from"node:fs";import
|
|
2
|
+
import m from"node:process";import{promises as l}from"node:fs";import h from"node:url";import r from"node:path";import{spawn as g}from"node:child_process";import{program as n}from"commander";var v=h.fileURLToPath(import.meta.url),a=r.dirname(v);n.name("@design-edito/cli").description("The home of @design-edito/cli's project").option("-v, --version","output the current version").action(async t=>"version"in t?await p():n.help());n.command("list").description("list all the available commands").action(j);n.command("version").description("print current version of the package").action(p);var w=await c();w.forEach(t=>{n.command(t,{hidden:!0}).allowUnknownOption(!0).action(async(...i)=>{let[o,e,s,...d]=m.argv;if(s===void 0)return n.help();if(!(await c()).includes(s))return n.help();let u=r.join(a,"../",s,"index.js");g(u,d,{stdio:"inherit"}).on("error",f=>console.error(`Failed to start subprogram '${s}':`,f))})});n.parse(m.argv);async function c(){let t=r.join(a,"assets/list.txt");return(await l.readFile(t,{encoding:"utf-8"})).split(`
|
|
3
3
|
`).map(o=>o.trim())}async function j(){let i=(await c()).map(o=>{let e=Object.assign(new Array(24).fill(" "),o.split("")).join("");return o==="cli"?`${e} # npx @design-edito/cli help`:`${e} # npx @design-edito/cli ${o} help`}).join(`
|
|
4
|
-
`);console.log(i)}async function
|
|
4
|
+
`);console.log(i)}async function p(){let t=r.join(a,"assets/version.txt"),i=await l.readFile(t,{encoding:"utf-8"});console.log(i)}
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/cli/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cli/index.ts"],
|
|
4
|
-
"sourcesContent": ["import process from 'node:process'\nimport { promises as fs } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nprogram\n .name('@design-edito/cli')\n .description('The home of @design-edito/cli\\'s project')\n \nprogram\n .command('list')\n .description('list all the available commands')\n .action(printCommands)\n\nprogram\n .command('version')\n .description('print current version of the package')\n .action(printVersion)\n\nconst subCommands = await listCommands()\nsubCommands.forEach(subCommand => {\n program\n .command(subCommand, { hidden: true })\n .allowUnknownOption(true)\n .action(async (...args) => {\n const [_nodePath, _thisPath, targetCommand, ...forwardedArgs] = process.argv\n if (targetCommand === undefined) return program.help()\n const commandsList = await listCommands()\n if (!commandsList.includes(targetCommand)) return program.help()\n const subprogramPath = path.join(__dirname, '../', targetCommand, 'index.js')\n const subprocess = spawn(subprogramPath, forwardedArgs, { stdio: 'inherit' })\n subprocess.on('error', err => console.error(`Failed to start subprogram '${targetCommand}':`, err))\n })\n})\n\nprogram.parse(process.argv)\n\nasync function listCommands () {\n const listFilePath = path.join(__dirname, 'assets/list.txt')\n const list = await fs.readFile(listFilePath, { encoding: 'utf-8' })\n return list.split('\\n').map(e => e.trim())\n}\n\nasync function printCommands () {\n const list = await listCommands()\n const output = list\n .map(c => {\n const twentyFourCharName = Object.assign(\n new Array(24).fill(' ') as string[],\n c.split('') as string[]\n ).join('')\n if (c === 'cli') return `${twentyFourCharName} # npx @design-edito/cli help`\n return `${twentyFourCharName} # npx @design-edito/cli ${c} help`\n })\n .join('\\n')\n console.log(output)\n return;\n}\n\nasync function printVersion () {\n const versionFilePath = path.join(__dirname, 'assets/version.txt')\n const version = await fs.readFile(versionFilePath, { encoding: 'utf-8' })\n console.log(version)\n return;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,MAAU,UAC/B,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YAExB,IAAMC,EAAaJ,EAAI,cAAc,YAAY,GAAG,EAC9CK,EAAYJ,EAAK,QAAQG,CAAU,EAEzCD,EACG,KAAK,mBAAmB,EACxB,YAAY,yCAA0C,
|
|
6
|
-
"names": ["process", "fs", "url", "path", "spawn", "program", "__filename", "__dirname", "
|
|
4
|
+
"sourcesContent": ["import process from 'node:process'\nimport { promises as fs } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nprogram\n .name('@design-edito/cli')\n .description('The home of @design-edito/cli\\'s project')\n .option('-v, --version', 'output the current version')\n .action(async options => 'version' in options\n ? await printVersion()\n : program.help())\n \nprogram\n .command('list')\n .description('list all the available commands')\n .action(printCommands)\n\nprogram\n .command('version')\n .description('print current version of the package')\n .action(printVersion)\n\nconst subCommands = await listCommands()\nsubCommands.forEach(subCommand => {\n program\n .command(subCommand, { hidden: true })\n .allowUnknownOption(true)\n .action(async (...args) => {\n const [_nodePath, _thisPath, targetCommand, ...forwardedArgs] = process.argv\n if (targetCommand === undefined) return program.help()\n const commandsList = await listCommands()\n if (!commandsList.includes(targetCommand)) return program.help()\n const subprogramPath = path.join(__dirname, '../', targetCommand, 'index.js')\n const subprocess = spawn(subprogramPath, forwardedArgs, { stdio: 'inherit' })\n subprocess.on('error', err => console.error(`Failed to start subprogram '${targetCommand}':`, err))\n })\n})\n\nprogram.parse(process.argv)\n\nasync function listCommands () {\n const listFilePath = path.join(__dirname, 'assets/list.txt')\n const list = await fs.readFile(listFilePath, { encoding: 'utf-8' })\n return list.split('\\n').map(e => e.trim())\n}\n\nasync function printCommands () {\n const list = await listCommands()\n const output = list\n .map(c => {\n const twentyFourCharName = Object.assign(\n new Array(24).fill(' ') as string[],\n c.split('') as string[]\n ).join('')\n if (c === 'cli') return `${twentyFourCharName} # npx @design-edito/cli help`\n return `${twentyFourCharName} # npx @design-edito/cli ${c} help`\n })\n .join('\\n')\n console.log(output)\n return;\n}\n\nasync function printVersion () {\n const versionFilePath = path.join(__dirname, 'assets/version.txt')\n const version = await fs.readFile(versionFilePath, { encoding: 'utf-8' })\n console.log(version)\n return;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,MAAU,UAC/B,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YAExB,IAAMC,EAAaJ,EAAI,cAAc,YAAY,GAAG,EAC9CK,EAAYJ,EAAK,QAAQG,CAAU,EAEzCD,EACG,KAAK,mBAAmB,EACxB,YAAY,yCAA0C,EACtD,OAAO,gBAAiB,4BAA4B,EACpD,OAAO,MAAMG,GAAW,YAAaA,EAClC,MAAMC,EAAa,EACnBJ,EAAQ,KAAK,CAAC,EAEpBA,EACG,QAAQ,MAAM,EACd,YAAY,iCAAiC,EAC7C,OAAOK,CAAa,EAEvBL,EACG,QAAQ,SAAS,EACjB,YAAY,sCAAsC,EAClD,OAAOI,CAAY,EAEtB,IAAME,EAAc,MAAMC,EAAa,EACvCD,EAAY,QAAQE,GAAc,CAChCR,EACG,QAAQQ,EAAY,CAAE,OAAQ,EAAK,CAAC,EACpC,mBAAmB,EAAI,EACvB,OAAO,SAAUC,IAAS,CACzB,GAAM,CAACC,EAAWC,EAAWC,EAAe,GAAGC,CAAa,EAAIlB,EAAQ,KACxE,GAAIiB,IAAkB,OAAW,OAAOZ,EAAQ,KAAK,EAErD,GAAI,EADiB,MAAMO,EAAa,GACtB,SAASK,CAAa,EAAG,OAAOZ,EAAQ,KAAK,EAC/D,IAAMc,EAAiBhB,EAAK,KAAKI,EAAW,MAAOU,EAAe,UAAU,EACzDb,EAAMe,EAAgBD,EAAe,CAAE,MAAO,SAAU,CAAC,EACjE,GAAG,QAASE,GAAO,QAAQ,MAAM,+BAA+BH,CAAa,KAAMG,CAAG,CAAC,CACpG,CAAC,CACL,CAAC,EAEDf,EAAQ,MAAML,EAAQ,IAAI,EAE1B,eAAeY,GAAgB,CAC7B,IAAMS,EAAelB,EAAK,KAAKI,EAAW,iBAAiB,EAE3D,OADa,MAAMN,EAAG,SAASoB,EAAc,CAAE,SAAU,OAAQ,CAAC,GACtD,MAAM;AAAA,CAAI,EAAE,IAAIC,GAAKA,EAAE,KAAK,CAAC,CAC3C,CAEA,eAAeZ,GAAiB,CAE9B,IAAMa,GADO,MAAMX,EAAa,GAE7B,IAAIY,GAAK,CACR,IAAMC,EAAqB,OAAO,OAChC,IAAI,MAAM,EAAE,EAAE,KAAK,GAAG,EACtBD,EAAE,MAAM,EAAE,CACZ,EAAE,KAAK,EAAE,EACT,OAAIA,IAAM,MAAc,GAAGC,CAAkB,gCACtC,GAAGA,CAAkB,4BAA4BD,CAAC,OAC3D,CAAC,EACA,KAAK;AAAA,CAAI,EACZ,QAAQ,IAAID,CAAM,CAEpB,CAEA,eAAed,GAAgB,CAC7B,IAAMiB,EAAkBvB,EAAK,KAAKI,EAAW,oBAAoB,EAC3DoB,EAAU,MAAM1B,EAAG,SAASyB,EAAiB,CAAE,SAAU,OAAQ,CAAC,EACxE,QAAQ,IAAIC,CAAO,CAErB",
|
|
6
|
+
"names": ["process", "fs", "url", "path", "spawn", "program", "__filename", "__dirname", "options", "printVersion", "printCommands", "subCommands", "listCommands", "subCommand", "args", "_nodePath", "_thisPath", "targetCommand", "forwardedArgs", "subprogramPath", "err", "listFilePath", "e", "output", "c", "twentyFourCharName", "versionFilePath", "version"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import esbuild from 'esbuild'
|
|
2
|
+
|
|
3
|
+
esbuild.build({
|
|
4
|
+
entryPoints: ['src/index.ts'],
|
|
5
|
+
outdir: 'dist',
|
|
6
|
+
bundle: true,
|
|
7
|
+
sourcemap: true,
|
|
8
|
+
platform: 'node',
|
|
9
|
+
target: 'node16',
|
|
10
|
+
format: 'esm',
|
|
11
|
+
logLevel: 'info',
|
|
12
|
+
external: [
|
|
13
|
+
'express',
|
|
14
|
+
'cookie-parser',
|
|
15
|
+
'morgan',
|
|
16
|
+
'debug',
|
|
17
|
+
'util'
|
|
18
|
+
]
|
|
19
|
+
}).catch(() => process.exit(1))
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "-",
|
|
2
|
+
"name": "<<@mxfb/cli----replace-with-name>>",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build:src": "npx
|
|
7
|
+
"build:src:public": "npx cpx 'src/public/**/*' dist/public",
|
|
8
|
+
"check:src": "npx tsc -p src/tsconfig.json --noEmit",
|
|
9
|
+
"build:src": "node esbuild.config.js && npm run build:src:public",
|
|
8
10
|
"watch:src": "npm run build:src && npx chokidar 'src/**/*' -c 'npm run build:src'",
|
|
9
11
|
"serve": "npx nodemon ./dist/index.js",
|
|
10
12
|
"start:nowatch": "npm run build:src && npm run serve",
|
|
11
13
|
"start": "npx concurrently -n 'watch:src ,serve ' 'npm run watch:src' 'npm run serve'"
|
|
12
14
|
},
|
|
13
15
|
"dependencies": {
|
|
14
|
-
"cookie-parser": "
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"cookie-parser": "^1.4.7",
|
|
17
|
+
"cors": "^2.8.5",
|
|
18
|
+
"debug": "^4.4.0",
|
|
19
|
+
"esbuild": "^0.25.0",
|
|
20
|
+
"express": "^4.21.2",
|
|
21
|
+
"morgan": "^1.10.0",
|
|
22
|
+
"typescript": "^5.7.3"
|
|
18
23
|
},
|
|
19
24
|
"devDependencies": {
|
|
20
|
-
"@types/cookie-parser": "^1.4.
|
|
25
|
+
"@types/cookie-parser": "^1.4.8",
|
|
26
|
+
"@types/cors": "^2.8.17",
|
|
21
27
|
"@types/debug": "^4.1.12",
|
|
22
|
-
"@types/express": "^
|
|
28
|
+
"@types/express": "^5.0.0",
|
|
23
29
|
"@types/morgan": "^1.9.9",
|
|
24
|
-
"@types/node": "^22.
|
|
30
|
+
"@types/node": "^22.13.4",
|
|
25
31
|
"chokidar-cli": "^3.0.0",
|
|
26
|
-
"concurrently": "^
|
|
27
|
-
"esbuild": "^0.23.0",
|
|
28
|
-
"typescript": "^5.5.4"
|
|
32
|
+
"concurrently": "^9.1.2"
|
|
29
33
|
}
|
|
30
34
|
}
|
|
@@ -1,62 +1,26 @@
|
|
|
1
|
-
import http from 'node:http'
|
|
2
1
|
import path from 'node:path'
|
|
3
2
|
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import express from 'express'
|
|
5
3
|
import cookieParser from 'cookie-parser'
|
|
4
|
+
import cors from 'cors'
|
|
5
|
+
import express from 'express'
|
|
6
6
|
import logger from 'morgan'
|
|
7
|
-
import
|
|
8
|
-
import indexRouter from './routes/index.js'
|
|
7
|
+
import { serve } from './www'
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
const port = normalizePort(process.env.PORT ?? '3000')
|
|
9
|
+
// App setup
|
|
12
10
|
const app = express()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
app.use(logger('dev'))
|
|
11
|
+
app.use(cors()) // [WIP] configure cors and allowed origins
|
|
12
|
+
app.use(logger('dev')) // [WIP] configure logger for prod an all
|
|
16
13
|
app.use(express.json())
|
|
17
14
|
app.use(express.urlencoded({ extended: false }))
|
|
18
15
|
app.use(cookieParser())
|
|
19
|
-
app.use(express.static(path.join(__dirname, 'public')))
|
|
20
|
-
app.use('/', indexRouter)
|
|
21
|
-
app.set('port', port)
|
|
22
|
-
|
|
23
|
-
const server = http.createServer(app)
|
|
24
|
-
|
|
25
|
-
server.listen(port)
|
|
26
|
-
server.on('error', onError)
|
|
27
|
-
server.on('listening', onListening)
|
|
28
|
-
|
|
29
|
-
function normalizePort (val: string) {
|
|
30
|
-
var port = parseInt(val, 10)
|
|
31
|
-
if (isNaN(port)) return val
|
|
32
|
-
if (port >= 0) return port
|
|
33
|
-
return false
|
|
34
|
-
}
|
|
35
16
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
// Static files
|
|
18
|
+
const ROOT = path.dirname(fileURLToPath(import.meta.url))
|
|
19
|
+
const PUBLIC = path.join(ROOT, 'public')
|
|
20
|
+
app.use(express.static(PUBLIC))
|
|
40
21
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port
|
|
44
|
-
switch (error.code) {
|
|
45
|
-
case 'EACCES':
|
|
46
|
-
console.error(bind + ' requires elevated privileges')
|
|
47
|
-
process.exit(1)
|
|
48
|
-
break
|
|
49
|
-
case 'EADDRINUSE':
|
|
50
|
-
console.error(bind + ' is already in use')
|
|
51
|
-
process.exit(1)
|
|
52
|
-
break
|
|
53
|
-
default:
|
|
54
|
-
throw error
|
|
55
|
-
}
|
|
56
|
-
}
|
|
22
|
+
// Routes
|
|
23
|
+
app.get('/', (req, res) => res.send({ data: true }))
|
|
57
24
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + (addr?.port ?? '')
|
|
61
|
-
debug('Listening on ' + bind)
|
|
62
|
-
}
|
|
25
|
+
// Start server
|
|
26
|
+
serve(app)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<script type="module" src="./index.js"></script>
|
|
7
|
+
<link rel="stylesheet" href="./index.css">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<h1>LM-Publisher</h1>
|
|
11
|
+
|
|
12
|
+
<button class="create-random-project">Create random project</button>
|
|
13
|
+
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const $responses = document.querySelector('.requests')
|
|
2
|
+
const $createRandomProject = document.querySelector('.create-random-project')
|
|
3
|
+
|
|
4
|
+
async function fetchAndLog (url, method, body) {
|
|
5
|
+
const id = Math.random().toString(36).slice(2)
|
|
6
|
+
console.log('%cSending request...', 'font-weight: 600')
|
|
7
|
+
console.log('id:', id)
|
|
8
|
+
console.log(`${method}:`, url)
|
|
9
|
+
const response = await window.fetch(url, {
|
|
10
|
+
method,
|
|
11
|
+
body: JSON.stringify(body),
|
|
12
|
+
headers: { 'Content-Type': 'application/json' }
|
|
13
|
+
})
|
|
14
|
+
const json = await response.json()
|
|
15
|
+
console.log('%cReceived response', 'font-weight: 600')
|
|
16
|
+
console.log('id:', id)
|
|
17
|
+
console.log(`${method}:`, url)
|
|
18
|
+
console.log('body:', body)
|
|
19
|
+
console.log('response:', response)
|
|
20
|
+
console.log('json:', json)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
$createRandomProject.addEventListener('click', () => {
|
|
24
|
+
fetchAndLog('http://localhost:3000/projects/create', 'POST', {
|
|
25
|
+
name: 'Mon premier projet :\')',
|
|
26
|
+
publicationTargetDate: Date.now(),
|
|
27
|
+
sourcesIds: [],
|
|
28
|
+
articlesIds: [],
|
|
29
|
+
assetsIds: [],
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ESNext",
|
|
4
4
|
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "
|
|
5
|
+
"moduleResolution": "Node",
|
|
6
6
|
"esModuleInterop": true,
|
|
7
|
+
"declaration": true,
|
|
7
8
|
"forceConsistentCasingInFileNames": true,
|
|
8
9
|
"strict": true,
|
|
9
10
|
"skipLibCheck": true,
|
|
10
|
-
"noUncheckedIndexedAccess": true
|
|
11
|
-
|
|
11
|
+
"noUncheckedIndexedAccess": true,
|
|
12
|
+
"strictNullChecks": true,
|
|
13
|
+
"noEmit": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["./**/*"]
|
|
12
16
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import http from 'node:http'
|
|
2
|
+
import debugModule from 'debug'
|
|
3
|
+
import { Express } from 'express'
|
|
4
|
+
|
|
5
|
+
interface NodeError extends Error {
|
|
6
|
+
syscall?: string
|
|
7
|
+
code?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function serve (app: Express) {
|
|
11
|
+
const port = normalizePort(process.env.PORT ?? '3000')
|
|
12
|
+
const debug = debugModule('<<@mxfb/cli----replace-with-name>>:server')
|
|
13
|
+
const server = http.createServer(app)
|
|
14
|
+
app.set('port', port)
|
|
15
|
+
server.listen(port)
|
|
16
|
+
server.on('error', (error: NodeError) => {
|
|
17
|
+
if (error.syscall !== 'listen') throw error
|
|
18
|
+
var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port
|
|
19
|
+
switch (error.code) {
|
|
20
|
+
case 'EACCES':
|
|
21
|
+
console.error(bind + ' requires elevated privileges')
|
|
22
|
+
return process.exit(1)
|
|
23
|
+
case 'EADDRINUSE':
|
|
24
|
+
console.error(bind + ' is already in use')
|
|
25
|
+
return process.exit(1)
|
|
26
|
+
default:
|
|
27
|
+
throw error
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
server.on('listening', () => {
|
|
31
|
+
var addr = server.address()
|
|
32
|
+
var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + (addr?.port ?? '')
|
|
33
|
+
debug('Listening on ' + bind)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
function normalizePort (val: string) {
|
|
37
|
+
var port = parseInt(val, 10)
|
|
38
|
+
if (isNaN(port)) return val
|
|
39
|
+
if (port >= 0) return port
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
FROM node:20-alpine AS builder
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
COPY package*.json ./
|
|
5
|
+
COPY esbuild.config.js ./esbuild.config.js
|
|
6
|
+
COPY src ./src
|
|
7
|
+
RUN npm install --omit=dev
|
|
8
|
+
RUN npm run build:src
|
|
9
|
+
|
|
10
|
+
FROM node:20-alpine AS runner
|
|
11
|
+
|
|
12
|
+
WORKDIR /app
|
|
13
|
+
COPY --from=builder /app/dist ./dist
|
|
14
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
15
|
+
COPY package.json ./
|
|
16
|
+
EXPOSE 3000
|
|
17
|
+
|
|
18
|
+
CMD ["node", "dist/index.js"]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Mode (development, production)
|
|
2
|
+
MODE=development
|
|
3
|
+
|
|
4
|
+
# Location
|
|
5
|
+
HOST=localhost:3000
|
|
6
|
+
|
|
7
|
+
# Database
|
|
8
|
+
DB_USR=db-user
|
|
9
|
+
DB_PWD=db-pwd
|
|
10
|
+
DB_URL=db-url
|
|
11
|
+
DB_OPT=db_opt1=true&db_opt2=false
|
|
12
|
+
|
|
13
|
+
# Agenda
|
|
14
|
+
DB_RESERVED_AGENDA_JOBS_COLLECTION_NAME=__AgendaJobs
|
|
15
|
+
|
|
16
|
+
# ROOT User
|
|
17
|
+
ROOT_USER_ID=000000000000000000000000
|
|
18
|
+
ROOT_USER_NAME=ROOT
|
|
19
|
+
ROOT_USER_EMAIL=root@root.com
|
|
20
|
+
ROOT_USER_PWD=rootpwd
|
|
21
|
+
|
|
22
|
+
# User email validation token
|
|
23
|
+
USER_EMAIL_VALIDATION_TOKEN_LIFETIME_MINUTES=60
|
|
24
|
+
|
|
25
|
+
# JWT
|
|
26
|
+
JWT_SECRET=jwt-secret
|
|
27
|
+
ACCESS_TOKEN_EXPIRATION_SECONDS=900 # 15 minutes
|
|
28
|
+
ACCESS_TOKEN_RENEWAL_THRESHOLD=300 # 5 minutes
|
|
29
|
+
REFRESH_TOKEN_EXPIRATION_SECONDS=86400 # 1 day
|
|
30
|
+
ACCESS_TOKEN_MAX_REFRESH_COUNT=5
|
|
31
|
+
REFRESH_TOKEN_MAX_REFRESH_COUNT=5
|
|
32
|
+
|
|
33
|
+
# Emailing
|
|
34
|
+
MAILERSEND_API_KEY=mailersend-api-key
|
|
35
|
+
EMAILER_EMAIL=noreply@noreply.com
|
|
36
|
+
EMAILER_NAME=Noreply
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import esbuild from 'esbuild'
|
|
2
|
+
|
|
3
|
+
esbuild.build({
|
|
4
|
+
entryPoints: ['src/index.ts'],
|
|
5
|
+
outdir: 'dist',
|
|
6
|
+
bundle: true,
|
|
7
|
+
sourcemap: true,
|
|
8
|
+
platform: 'node',
|
|
9
|
+
target: 'node16',
|
|
10
|
+
format: 'esm',
|
|
11
|
+
logLevel: 'info',
|
|
12
|
+
external: [
|
|
13
|
+
'mailersend',
|
|
14
|
+
'express',
|
|
15
|
+
'cookie-parser',
|
|
16
|
+
'morgan',
|
|
17
|
+
'mongoose',
|
|
18
|
+
'dotenv',
|
|
19
|
+
'debug',
|
|
20
|
+
'@mapbox',
|
|
21
|
+
'jsonwebtoken',
|
|
22
|
+
'bcrypt',
|
|
23
|
+
'util',
|
|
24
|
+
'agenda'
|
|
25
|
+
]
|
|
26
|
+
}).catch(() => process.exit(1))
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Created by https://www.toptal.com/developers/gitignore/api/node,osx,linux,windows
|
|
2
|
+
# Edit at https://www.toptal.com/developers/gitignore?templates=node,osx,linux,windows
|
|
3
|
+
|
|
4
|
+
### Linux ###
|
|
5
|
+
*~
|
|
6
|
+
|
|
7
|
+
# temporary files which can be created if a process still has a handle open of a deleted file
|
|
8
|
+
.fuse_hidden*
|
|
9
|
+
|
|
10
|
+
# KDE directory preferences
|
|
11
|
+
.directory
|
|
12
|
+
|
|
13
|
+
# Linux trash folder which might appear on any partition or disk
|
|
14
|
+
.Trash-*
|
|
15
|
+
|
|
16
|
+
# .nfs files are created when an open file is removed but is still being accessed
|
|
17
|
+
.nfs*
|
|
18
|
+
|
|
19
|
+
### Node ###
|
|
20
|
+
# Logs
|
|
21
|
+
logs
|
|
22
|
+
*.log
|
|
23
|
+
npm-debug.log*
|
|
24
|
+
yarn-debug.log*
|
|
25
|
+
yarn-error.log*
|
|
26
|
+
lerna-debug.log*
|
|
27
|
+
.pnpm-debug.log*
|
|
28
|
+
|
|
29
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
30
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
31
|
+
|
|
32
|
+
# Runtime data
|
|
33
|
+
pids
|
|
34
|
+
*.pid
|
|
35
|
+
*.seed
|
|
36
|
+
*.pid.lock
|
|
37
|
+
|
|
38
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
39
|
+
lib-cov
|
|
40
|
+
|
|
41
|
+
# Coverage directory used by tools like istanbul
|
|
42
|
+
coverage
|
|
43
|
+
*.lcov
|
|
44
|
+
|
|
45
|
+
# nyc test coverage
|
|
46
|
+
.nyc_output
|
|
47
|
+
|
|
48
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
49
|
+
.grunt
|
|
50
|
+
|
|
51
|
+
# Bower dependency directory (https://bower.io/)
|
|
52
|
+
bower_components
|
|
53
|
+
|
|
54
|
+
# node-waf configuration
|
|
55
|
+
.lock-wscript
|
|
56
|
+
|
|
57
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
58
|
+
build/Release
|
|
59
|
+
|
|
60
|
+
# Dependency directories
|
|
61
|
+
node_modules/
|
|
62
|
+
jspm_packages/
|
|
63
|
+
|
|
64
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
65
|
+
web_modules/
|
|
66
|
+
|
|
67
|
+
# TypeScript cache
|
|
68
|
+
*.tsbuildinfo
|
|
69
|
+
|
|
70
|
+
# Optional npm cache directory
|
|
71
|
+
.npm
|
|
72
|
+
|
|
73
|
+
# Optional eslint cache
|
|
74
|
+
.eslintcache
|
|
75
|
+
|
|
76
|
+
# Optional stylelint cache
|
|
77
|
+
.stylelintcache
|
|
78
|
+
|
|
79
|
+
# Microbundle cache
|
|
80
|
+
.rpt2_cache/
|
|
81
|
+
.rts2_cache_cjs/
|
|
82
|
+
.rts2_cache_es/
|
|
83
|
+
.rts2_cache_umd/
|
|
84
|
+
|
|
85
|
+
# Optional REPL history
|
|
86
|
+
.node_repl_history
|
|
87
|
+
|
|
88
|
+
# Output of 'npm pack'
|
|
89
|
+
*.tgz
|
|
90
|
+
|
|
91
|
+
# Yarn Integrity file
|
|
92
|
+
.yarn-integrity
|
|
93
|
+
|
|
94
|
+
# dotenv environment variable files
|
|
95
|
+
.env
|
|
96
|
+
.env.development.local
|
|
97
|
+
.env.test.local
|
|
98
|
+
.env.production.local
|
|
99
|
+
.env.local
|
|
100
|
+
|
|
101
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
102
|
+
.cache
|
|
103
|
+
.parcel-cache
|
|
104
|
+
|
|
105
|
+
# Next.js build output
|
|
106
|
+
.next
|
|
107
|
+
out
|
|
108
|
+
|
|
109
|
+
# Nuxt.js build / generate output
|
|
110
|
+
.nuxt
|
|
111
|
+
dist
|
|
112
|
+
|
|
113
|
+
# Gatsby files
|
|
114
|
+
.cache/
|
|
115
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
116
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
117
|
+
# public
|
|
118
|
+
|
|
119
|
+
# vuepress build output
|
|
120
|
+
.vuepress/dist
|
|
121
|
+
|
|
122
|
+
# vuepress v2.x temp and cache directory
|
|
123
|
+
.temp
|
|
124
|
+
|
|
125
|
+
# Docusaurus cache and generated files
|
|
126
|
+
.docusaurus
|
|
127
|
+
|
|
128
|
+
# Serverless directories
|
|
129
|
+
.serverless/
|
|
130
|
+
|
|
131
|
+
# FuseBox cache
|
|
132
|
+
.fusebox/
|
|
133
|
+
|
|
134
|
+
# DynamoDB Local files
|
|
135
|
+
.dynamodb/
|
|
136
|
+
|
|
137
|
+
# TernJS port file
|
|
138
|
+
.tern-port
|
|
139
|
+
|
|
140
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
141
|
+
.vscode-test
|
|
142
|
+
|
|
143
|
+
# yarn v2
|
|
144
|
+
.yarn/cache
|
|
145
|
+
.yarn/unplugged
|
|
146
|
+
.yarn/build-state.yml
|
|
147
|
+
.yarn/install-state.gz
|
|
148
|
+
.pnp.*
|
|
149
|
+
|
|
150
|
+
### Node Patch ###
|
|
151
|
+
# Serverless Webpack directories
|
|
152
|
+
.webpack/
|
|
153
|
+
|
|
154
|
+
# Optional stylelint cache
|
|
155
|
+
|
|
156
|
+
# SvelteKit build / generate output
|
|
157
|
+
.svelte-kit
|
|
158
|
+
|
|
159
|
+
### OSX ###
|
|
160
|
+
# General
|
|
161
|
+
.DS_Store
|
|
162
|
+
.AppleDouble
|
|
163
|
+
.LSOverride
|
|
164
|
+
|
|
165
|
+
# Icon must end with two \r
|
|
166
|
+
Icon
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# Thumbnails
|
|
170
|
+
._*
|
|
171
|
+
|
|
172
|
+
# Files that might appear in the root of a volume
|
|
173
|
+
.DocumentRevisions-V100
|
|
174
|
+
.fseventsd
|
|
175
|
+
.Spotlight-V100
|
|
176
|
+
.TemporaryItems
|
|
177
|
+
.Trashes
|
|
178
|
+
.VolumeIcon.icns
|
|
179
|
+
.com.apple.timemachine.donotpresent
|
|
180
|
+
|
|
181
|
+
# Directories potentially created on remote AFP share
|
|
182
|
+
.AppleDB
|
|
183
|
+
.AppleDesktop
|
|
184
|
+
Network Trash Folder
|
|
185
|
+
Temporary Items
|
|
186
|
+
.apdisk
|
|
187
|
+
|
|
188
|
+
### Windows ###
|
|
189
|
+
# Windows thumbnail cache files
|
|
190
|
+
Thumbs.db
|
|
191
|
+
Thumbs.db:encryptable
|
|
192
|
+
ehthumbs.db
|
|
193
|
+
ehthumbs_vista.db
|
|
194
|
+
|
|
195
|
+
# Dump file
|
|
196
|
+
*.stackdump
|
|
197
|
+
|
|
198
|
+
# Folder config file
|
|
199
|
+
[Dd]esktop.ini
|
|
200
|
+
|
|
201
|
+
# Recycle Bin used on file shares
|
|
202
|
+
$RECYCLE.BIN/
|
|
203
|
+
|
|
204
|
+
# Windows Installer files
|
|
205
|
+
*.cab
|
|
206
|
+
*.msi
|
|
207
|
+
*.msix
|
|
208
|
+
*.msm
|
|
209
|
+
*.msp
|
|
210
|
+
|
|
211
|
+
# Windows shortcuts
|
|
212
|
+
*.lnk
|
|
213
|
+
|
|
214
|
+
# End of https://www.toptal.com/developers/gitignore/api/node,osx,linux,windows
|