Skip to content

Commit

Permalink
add bin
Browse files Browse the repository at this point in the history
change env variables
  • Loading branch information
TimurRin committed Nov 19, 2024
1 parent eb08774 commit 9896850
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
3 changes: 3 additions & 0 deletions bin/snapcrud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

import "../dist/index.js";
2 changes: 1 addition & 1 deletion esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const OUT_WEB_FOLDER = IS_NPM_BUNDLE ? "dist/assets" : "build/bundle/assets";
const nodeModules = IS_NPM_BUNDLE ? getNodeModules() : [];

const myVars = {
'process.env.ANCA_BUILD_PREFIX': markBuild(),
'process.env.SNAPCRUD_BUILD_PREFIX': markBuild(),
}

const buildOptions = {
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"name": "snapcrud",
"version": "0.0.0",
"license": "ISC",
"bin": {
"snapcrud": "./bin/snapcrud.js"
},
"files": [
"bin",
"dist"
],
"type": "module",
Expand Down
18 changes: 9 additions & 9 deletions src/config/database.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import knex from "knex";

const databaseName = process.env.DB_NAME || "snapcrud_generic";
const databaseName = process.env.SNAPCRUD_DB_NAME || "snapcrud_generic";

const knexDbInit = knex({
client: "mysql2",
connection: {
host: process.env.DB_HOST || "localhost",
password: process.env.DB_PASSWORD || "",
port: parseInt(process.env.DB_PORT || "3306") || 3306,
user: process.env.DB_USER || "root",
host: process.env.SNAPCRUD_DB_HOST || "localhost",
password: process.env.SNAPCRUD_DB_PASSWORD || "",
port: parseInt(process.env.SNAPCRUD_DB_PORT || "3306") || 3306,
user: process.env.SNAPCRUD_DB_USER || "root",
},
pool: { max: 10, min: 0 },
});
Expand All @@ -20,10 +20,10 @@ export default knex({
client: "mysql2",
connection: {
database: databaseName,
host: process.env.DB_HOST || "localhost",
password: process.env.DB_PASSWORD || "",
port: parseInt(process.env.DB_PORT || "3306") || 3306,
user: process.env.DB_USER || "root",
host: process.env.SNAPCRUD_DB_HOST || "localhost",
password: process.env.SNAPCRUD_DB_PASSWORD || "",
port: parseInt(process.env.SNAPCRUD_DB_PORT || "3306") || 3306,
user: process.env.SNAPCRUD_DB_USER || "root",
},
pool: { max: 10, min: 0 },
});
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import app from "./express.js";
import { logger } from "./utils/logger.js";
import { getProjectVersion } from "./utils/version.js";

const host = process.env.HOST || "127.0.0.1";
const port = parseInt(process.env.PORT || "3000");
const host = process.env.SNAPCRUD_HOST || "127.0.0.1";
const port = parseInt(process.env.SNAPCRUD_PORT || "3000");

app.listen(port, host, () => {
logger.info(
getStartupWelcomeText(
"cinnabar-id",
"snapcrud",
getProjectVersion(),
process.env.NODE_ENV === "production",
"http",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import winston from "winston";

const logger = winston.createLogger({
format: winston.format.simple(),
level: process.env.LOGGER_LEVEL || "verbose",
level: process.env.SNAPCRUD_LOGGER_LEVEL || "verbose",
transports: [new winston.transports.Console()],
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CINNABAR_PROJECT_VERSION } from "../cinnabar.js";

const version =
CINNABAR_PROJECT_VERSION + (process.env.ANCA_BUILD_PREFIX || "");
CINNABAR_PROJECT_VERSION + (process.env.SNAPCRUD_BUILD_PREFIX || "");

/**
*
Expand Down

0 comments on commit 9896850

Please sign in to comment.