This commit is contained in:
payacom
2026-08-31 20:45:41 +03:30
parent fa9f23c61d
commit 3f416a7a60
367 changed files with 621895 additions and 6443 deletions

87
scripts/verify-backend.js Normal file
View File

@@ -0,0 +1,87 @@
#!/usr/bin/env node
/**
* Run from modstagram-back root on the server:
* node scripts/verify-backend.js
*/
const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
const root = path.join(__dirname, '..')
let failed = false
function fail (message) {
console.error('FAIL:', message)
failed = true
}
function ok (message) {
console.log('OK:', message)
}
function walkJs (dir, out = []) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
if (entry.name === 'node_modules' || entry.name === 'dist') continue
const full = path.join(dir, entry.name)
if (entry.isDirectory()) walkJs(full, out)
else if (entry.name.endsWith('.js')) out.push(full)
}
return out
}
console.log('Checking merge conflicts...')
const conflictPattern = /^<<<<<<<|^=======|^>>>>>>>/
for (const file of walkJs(root)) {
const firstLines = fs.readFileSync(file, 'utf8').split('\n').slice(0, 3)
if (firstLines.some((line) => conflictPattern.test(line.trim()))) {
fail(`merge conflict marker in ${path.relative(root, file)}`)
}
}
if (!failed) ok('no merge conflict markers')
console.log('Syntax check...')
const critical = [
'index.js',
'routes/index.js',
'controllers/application/users/getUserController.js',
'controllers/application/projects/getProjectController.js',
'controllers/application/stories/storyController.js',
'controllers/panel/projects/projectController.js'
]
for (const rel of critical) {
try {
execSync(`node --check "${path.join(root, rel)}"`, { stdio: 'pipe' })
ok(rel)
} catch {
fail(`syntax error in ${rel}`)
}
}
console.log('Loading routes...')
try {
process.chdir(root)
require('../routes/index.js')
ok('routes/index.js loaded')
} catch (error) {
fail(`routes load: ${error.message}`)
}
console.log('Loading getUserController...')
try {
const mod = require('../controllers/application/users/getUserController.js')
if (typeof mod.getPostsWeb !== 'function') {
fail('getPostsWeb export missing')
} else {
ok('getPostsWeb export')
}
} catch (error) {
fail(`getUserController: ${error.message}`)
}
if (failed) {
console.error('\nBackend verification FAILED')
process.exit(1)
}
console.log('\nBackend verification PASSED')
process.exit(0)