fix(seed): convert scripts/setup-neon-db.js from CJS to ESM (Node 22.x compat)
Brief 2 of drop-public-setup. Closes Decision D — pure module-system
conversion of scripts/setup-neon-db.js so `npm run setup-db` actually
runs on Node 22.x where package.json has "type": "module" (added by
bump-next-js for ESLint v9 flat-config support).
Before this commit, `npm run setup-db` threw:
ReferenceError: require is not defined in ES module scope
After this commit, brief 1's ADMIN_INITIAL_PASSWORD env-var gate actually
fires as documented.
Changes (all in scripts/setup-neon-db.js):
- require('dotenv').config(...) → import dotenv + dotenv.config(...)
- require('@neondatabase/serverless') → import { neon }
- inline require('bcryptjs') hoisted to top-of-file import bcrypt
- no functional changes; same DDL, same env-var gate, same console.logs
Smoke verification: see PR description.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
792439b5eb
commit
b63b5090cc
1 changed files with 4 additions and 3 deletions
|
|
@ -8,9 +8,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Load environment variables from .env.local
|
// Load environment variables from .env.local
|
||||||
require('dotenv').config({ path: '.env.local' });
|
import dotenv from 'dotenv';
|
||||||
|
dotenv.config({ path: '.env.local' });
|
||||||
|
|
||||||
const { neon } = require('@neondatabase/serverless');
|
import { neon } from '@neondatabase/serverless';
|
||||||
|
import bcrypt from 'bcryptjs';
|
||||||
|
|
||||||
async function setupNeonDatabase() {
|
async function setupNeonDatabase() {
|
||||||
const adminPassword = process.env.ADMIN_INITIAL_PASSWORD;
|
const adminPassword = process.env.ADMIN_INITIAL_PASSWORD;
|
||||||
|
|
@ -139,7 +141,6 @@ async function setupNeonDatabase() {
|
||||||
console.log('✅ Created deck_cards table');
|
console.log('✅ Created deck_cards table');
|
||||||
|
|
||||||
// Create admin user
|
// Create admin user
|
||||||
const bcrypt = require('bcryptjs');
|
|
||||||
const hashedPassword = await bcrypt.hash(adminPassword, 12);
|
const hashedPassword = await bcrypt.hash(adminPassword, 12);
|
||||||
|
|
||||||
await sql`
|
await sql`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue