Initial commit

This commit is contained in:
meusinfirmary
2025-04-22 14:31:37 +07:00
commit b7e852126c
115 changed files with 23188 additions and 0 deletions

41
config/dbMysqlConn.js Normal file
View File

@ -0,0 +1,41 @@
const mysql = require('mysql');
const pool = mysql.createPool({
connectionLimit: process.env.CONNECTIONLIMIT,
host: process.env.DBHOST,
user: process.env.DBUSER,
password: process.env.DBPASSWORD,
database: process.env.DATABASE,
acquireTimeout: Number(process.env.ACQRTIMEOUT), // in ms
});
pool.getConnection((err, conn) => {
if (err) {
if (err.code === 'PROTOCOL_CONNECTION_LOST') {
console.error('Koneksi database ditutup.');
}
if (err.code === 'ER_CON_COUNT_ERROR') {
console.error('Basis data memiliki terlalu banyak koneksi.');
}
if (err.code === 'ECONNREFUSED') {
console.error('Koneksi database ditolak.');
}
console.error(err);
}
if (conn) conn.release();
return;
})
// pool.on('acquire', function (connection) {
// console.log('Connection %d acquired', connection.threadId);
// });
// pool.on('connection', function (connection) {
// console.log('Connection %d connect', connection.threadId);
// });
// pool.on('release', function (connection) {
// console.log('Connection %d released', connection.threadId);
// });
module.exports = pool;

3
config/netConn.js Normal file
View File

@ -0,0 +1,3 @@
const netConn = [];
module.exports = netConn;

22
config/request.js Normal file
View File

@ -0,0 +1,22 @@
const request = {
osm_reverse_geo: {
urlBase: 'https://nominatim.openstreetmap.org',
urlPath: 'reverse',
urlFull: 'https://nominatim.openstreetmap.org/reverse',
method: 'GET',
data: {
format: 'geojson' // xml,json,jsonv2,geojson(prefer),geocodejson
},
},
kodepos_region: {
urlBase: 'https://kodepos.vercel.app',
urlPath: 'search',
urlFull: 'https://kodepos.vercel.app/search',
method: 'GET',
data: {
json: 'true'
},
},
};
module.exports = request;

95
config/response.js Normal file
View File

@ -0,0 +1,95 @@
// default response by http code, maybe can be customed on controller
// custom format response, maybe can be customed on controller
const response = {
200: {
meta: {
code: '200',
type: 'success',
message: 'the request succeeded',
},
data: '',
},
201: {
meta: {
code: '201',
type: 'success',
message: 'resource created',
},
data: '',
},
202: {
meta: {
code: '202',
type: 'success',
message: 'resource accepted, but in progress',
},
data: '',
},
400: {
meta: {
code: '400',
type: 'bad_request',
message: 'bad request',
},
data: '',
},
401: {
meta: {
code: '401',
type: 'unauthenticated',
message: 'unauthenticated',
},
data: '',
},
404: {
meta: {
code: '404',
type: 'not_found',
message: 'resource not found',
},
data: '',
},
422: {
meta: {
code: '422',
type: 'unprocessable_entity',
message: 'bad input',
},
data: '',
},
500: {
meta: {
code: '500',
type: 'error',
message: 'error',
},
data: '',
},
email_unique: {
meta: {
code: '400',
type: 'email_unique',
message: 'email must be unique',
},
data: '',
},
wrong_password: {
meta: {
code: '400',
type: 'wrong_password',
message: 'wrong password',
},
data: '',
},
status_not_valid: {
meta: {
code: '400',
type: 'status_not_valid',
message: 'status not valid',
},
data: '',
},
};
module.exports = response;