Add skeleton
This commit is contained in:
43
.env.example
Normal file
43
.env.example
Normal file
@@ -0,0 +1,43 @@
|
||||
# # SQL DB Connection Colo
|
||||
# SQL_HOST=117.102.231.130
|
||||
# SQL_DATABASE=piu
|
||||
# SQL_USERNAME=sa
|
||||
# SQL_PASSWORD=@R3M4niA.
|
||||
# SQL_PORT=1433
|
||||
|
||||
SQL_HOST=203.153.114.226
|
||||
SQL_PORT=1112
|
||||
SQL_DATABASE=piu
|
||||
SQL_USERNAME=sa
|
||||
SQL_PASSWORD=piu123
|
||||
|
||||
# Application Port - express server listens on this port (default 9000).
|
||||
PORT=9528
|
||||
ENDPOINT_WA=http://203.153.114.226:9529/send
|
||||
# ENDPOINT_WA=http://localhost:9529/send
|
||||
ENDPOINT_FE=http://203.153.114.226:9527
|
||||
|
||||
# JWT access secret
|
||||
SECRET=secret
|
||||
|
||||
# JWT refresh secret
|
||||
REFRESH_SECRET=refreshsecret
|
||||
|
||||
# mail server settings
|
||||
# SMTP_FROM=youremail
|
||||
# SMTP_USER=youremail
|
||||
|
||||
# Stripe secret key - https://stripe.com/docs/keys
|
||||
# STRIPE_SECRET_KEY=sk_test_4eC39HqLyjWDarjtT1zdp7dc
|
||||
|
||||
# Google OAuth2.0 settings for sign in with Google - https://console.developers.google.com/
|
||||
# OAUTH_CLIENT_ID=287280guajkxxxxxxx.apps.googleusercontent.com
|
||||
# OAUTH_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxx
|
||||
# OAUTH_REFRESH_TOKEN=1//XXXXXXXXXX
|
||||
|
||||
# Google OAuth2.0 settings for sending emails - https://console.developers.google.com/
|
||||
# CLIENT_ID=938729280guajk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
|
||||
# CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
# REFRESH_TOKEN=1//XXXXXXXX
|
||||
|
||||
VITE_KEY_SESSION=PetekRombonganPetekMorekMorakMarek
|
||||
20
.eslintrc.js
Normal file
20
.eslintrc.js
Normal file
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
commonjs: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
extends: ["eslint:recommended"],
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
},
|
||||
parser: "babel-eslint",
|
||||
plugins: ["babel", "prettier"],
|
||||
rules: {
|
||||
"no-console": "warn",
|
||||
eqeqeq: "error",
|
||||
// "object-curly-spacing": ["error", "always"],
|
||||
// "arrow-spacing": ["error", { before: true, after: true }],
|
||||
},
|
||||
};
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
.env
|
||||
node_modules
|
||||
log
|
||||
tmp
|
||||
/public/**
|
||||
!public/.gitkeep
|
||||
.vscode
|
||||
request.http
|
||||
*.rest
|
||||
|
||||
8
.prettierrc
Normal file
8
.prettierrc
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"semi": true,
|
||||
"tabWidth": 2,
|
||||
"printWidth": 80,
|
||||
"singleQuote": false,
|
||||
"trailingComma": "es5",
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
30
app.js
Normal file
30
app.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const express = require("express");
|
||||
require("express-async-errors");
|
||||
const cors = require("cors");
|
||||
const morgan = require("morgan");
|
||||
const cookieParser = require("cookie-parser");
|
||||
const routes = require("./routes");
|
||||
const helmet = require("helmet");
|
||||
const compression = require("compression");
|
||||
const unknownEndpoint = require("./middleware/unKnownEndpoint");
|
||||
const { handleError } = require("./helpers/error");
|
||||
|
||||
const app = express();
|
||||
|
||||
app.set("trust proxy", 1);
|
||||
app.use(cors({ credentials: true, origin: true }));
|
||||
app.use(express.json());
|
||||
app.use(morgan("dev"));
|
||||
app.use(compression());
|
||||
app.use(helmet());
|
||||
app.use(cookieParser());
|
||||
|
||||
app.use("/api", routes);
|
||||
|
||||
app.get("/", (req, res) =>
|
||||
res.send("<h1 style='text-align: center'>HAHALO</h1>")
|
||||
);
|
||||
app.use(unknownEndpoint);
|
||||
app.use(handleError);
|
||||
|
||||
module.exports = app;
|
||||
14
ecosystem.config.js
Normal file
14
ecosystem.config.js
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: "bengkel-api",
|
||||
script: "./index.js", // Path to your entry file
|
||||
env: {
|
||||
NODE_ENV: "development",
|
||||
},
|
||||
env_production: {
|
||||
NODE_ENV: "production",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
10
index.js
Normal file
10
index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
require("dotenv").config({ path: __dirname + "/.env" });
|
||||
const http = require("http");
|
||||
const app = require("./app");
|
||||
const { logger } = require("./utils/logger");
|
||||
|
||||
const server = http.createServer(app);
|
||||
|
||||
const PORT = process.env.PORT || 9524;
|
||||
|
||||
server.listen(PORT, () => logger.info(`Magic happening on port: ${PORT}`));
|
||||
64
package.json
Normal file
64
package.json
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "server",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "cross-env NODE_ENV=production node index",
|
||||
"dev": "cross-env NODE_ENV=development && nodemon --legacy-watch",
|
||||
"test": "cross-env NODE_ENV=test jest --verbose --runInBand",
|
||||
"test:watch": "cross-env NODE_ENV=test jest --verbose --runInBand --watch",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
"coveragePathIgnorePatterns": [
|
||||
"/node_modules/"
|
||||
]
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.9.0",
|
||||
"bcrypt": "^5.1.1",
|
||||
"compression": "^1.7.4",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"cors": "^2.8.5",
|
||||
"crypto": "^1.0.1",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.18.2",
|
||||
"express-async-errors": "^3.1.1",
|
||||
"google-auth-library": "^8.7.0",
|
||||
"googleapis": "^112.0.0",
|
||||
"helmet": "^4.4.1",
|
||||
"joi": "^17.13.3",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"moment": "^2.29.4",
|
||||
"morgan": "^1.10.0",
|
||||
"mqtt": "^5.14.0",
|
||||
"mssql": "^11.0.1",
|
||||
"multer": "^1.4.5-lts.2",
|
||||
"nodemailer": "^6.8.0",
|
||||
"pg": "^8.8.0",
|
||||
"pino": "^6.11.3",
|
||||
"stripe": "^8.138.0",
|
||||
"svg-captcha": "^1.4.0",
|
||||
"swagger-ui-express": "^4.6.0",
|
||||
"uuid": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^10.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-babel": "^5.3.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"nodemon": "^2.0.20",
|
||||
"pino-pretty": "^4.8.0",
|
||||
"prettier": "^2.8.1",
|
||||
"supertest": "^6.3.3"
|
||||
}
|
||||
}
|
||||
9
utils/logger.js
Normal file
9
utils/logger.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const pino = require("pino");
|
||||
|
||||
// Create a logging instance
|
||||
const logger = pino({
|
||||
level: process.env.NODE_ENV === "production" ? "info" : "debug",
|
||||
prettyPrint: process.env.NODE_ENV !== "production",
|
||||
});
|
||||
|
||||
module.exports.logger = logger;
|
||||
Reference in New Issue
Block a user