Repository navigation
Setup and Configuration
This page explains what the setup wizard does, where Clone Sheet keeps its configuration, how ports are chosen and how to run migrations and other scripts by hand.
node setup.js # same as: npm run setupRun it from the project root; it reads and writes files relative to the current folder.
- Starts a temporary setup server on the first free port from 3000 and prints its URL.
- Shows the Database Setup form (defaults below).
- On Connect & Initialize, connects to the database server without selecting a database.
- Runs
SHOW DATABASES LIKE '<name>'and, if the database is missing,CREATE DATABASE. - Writes
config/config.json(used by the Sequelize CLI) for thedevelopment,testandproductionenvironments. - Writes
.env. - Runs
npx sequelize-cli db:migrateto create the tables. - Closes the setup server, starts the app on the first free port from the Application Port and redirects the browser to it.
If the connection fails, the form is shown again with the error message, for example
Connection failed: Access denied for user ....
| Field | Default | Written to |
|---|---|---|
| Host | 127.0.0.1 |
DB_HOST |
| Port | 3306 |
DB_PORT |
| Username | root |
DB_USER |
| Password | root |
DB_PASSWORD |
| Database Name | selldone |
DB_NAME |
| Application Port | 3010 |
PORT |
The app reads its settings from .env with dotenv:
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=root
DB_NAME=selldone
PORT=3010The wizard overwrites the whole file. The .env committed in the repository is a development example
(DB_PORT=4000, DB_NAME=test); run the wizard or edit the file before your first npm start.
The app connects through Sequelize with the mariadb dialect using config/config.js, which also reads .env.
The Sequelize CLI (migrations) uses config/config.json written by the wizard.
| Process | Port |
|---|---|
| Setup wizard | First free port from 3000. |
| App started by the wizard | First free port from the Application Port (default 3010). |
App started with npm start
|
PORT from .env, or 3000 if PORT is not set. |
# 1. Edit .env with your database settings
# 2. Create the database
npm run create-db # node create-database.js
# 3. Create the tables (make sure config/config.json matches .env)
npm run migrate # npx sequelize-cli db:migrate
# 4. Start
npm start| Script | Command | Purpose |
|---|---|---|
setup |
node setup.js |
Run the setup wizard. |
start |
node index.js |
Start the app. |
dev |
nodemon index.js |
Start the app and restart on file changes. |
migrate |
npx sequelize-cli db:migrate |
Apply migrations from migrations/. |
create-db |
node create-database.js |
CREATE DATABASE IF NOT EXISTS for DB_NAME. |
lint |
eslint . |
Lint the project. |
test |
— | No tests are defined yet. |
build |
— | No build step is required. |
| Path | Contents |
|---|---|
setup.js |
Setup wizard. |
index.js |
Express app and routes. |
config/ |
Database configuration for the app and the Sequelize CLI. |
migrations/ |
Table definitions (see Database Schema). |
models/ |
Sequelize models. |
routes/ |
API routes used by the web UI (auth, shop, sync, explorer, admin). |
src/TableConfig.js |
The list of syncable resources. |
src/utils/ResourceSync.js |
Generic batch sync for a resource. |
views/ |
EJS templates for the Setup, Sync, Database and Explore tabs. |
From DEV.md:
npx sequelize-cli migration:generate --name create-products
npx sequelize-cli model:generate --name Product --attributes title:string,price:float
node create-database.js
npx sequelize-cli db:migrate
node index.js