@arkstack/common 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/app.d.ts
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/lifecycle.ts","../src/network.ts","../src/prototypes.ts"],"sourcesContent":["export const bindGracefulShutdown = (shutdown: () => Promise<void> | void) => {\n [
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/lifecycle.ts","../src/network.ts","../src/prototypes.ts"],"sourcesContent":["export const bindGracefulShutdown = (shutdown: () => Promise<void> | void) => {\n ['SIGINT', 'SIGTERM', 'SIGQUIT'].forEach((signal) => {\n process.on(signal, async () => {\n await shutdown()\n })\n })\n}\n","import { detect } from 'detect-port'\n\nexport const bootWithDetectedPort = async (\n boot: (port: number) => Promise<void>,\n preferredPort: number = 3000,\n) => {\n const port = await detect(preferredPort)\n await boot(port)\n}\n\n\nexport const buildHtmlErrorResponse = ({\n message = 'An unexpected error occurred.',\n stack,\n title,\n code = 500,\n}: {\n message?: string;\n stack?: string;\n code?: number;\n title?: string;\n}) => {\n const titleMap: Record<number, string> = {\n 400: 'Bad Request',\n 401: 'Unauthorized',\n 403: 'Forbidden',\n 404: 'Not Found',\n 500: 'Internal Server Error',\n 502: 'Bad Gateway',\n 503: 'Service Unavailable',\n 504: 'Gateway Timeout',\n }\n\n title = titleMap[code] || title || 'Error'\n\n return `\n <html>\n <head>\n <title>${code} | ${title}</title>\n <style>\n body {\n font-family: Arial, sans-serif;\n background-color: #f8f8f8;\n color: #333;\n padding: 20px;\n }\n h1 {\n color: #e74c3c;\n }\n h3 {\n color: #3498db;\n }\n p {\n color: #555;\n }\n pre {\n background-color: #eee;\n padding: 10px;\n border-radius: 5px;\n overflow-x: auto;\n }\n </style>\n </head>\n <body>\n <h1>${code}</h1>\n <h3>${title}</h3>\n <p>${message}</p>\n ${stack ? `<h2>Stack Trace:</h2><pre>${stack}</pre>` : ''}\n </body>\n </html>\n `\n}","export const loadPrototypes = () => {\n String.prototype.titleCase = function () {\n return this.toLowerCase()\n .replace(/_/g, ' ')\n .replace(/-/g, ' ')\n .replace(/(?:^|\\s)\\w/g, function (match) {\n return match.toUpperCase()\n })\n }\n\n String.prototype.camelCase = function () {\n return this.replace(/(?:^\\w|[A-Z]|\\b\\w|\\s+)/g, function (match, index) {\n if (+match === 0) return '' // or if (/\\s+/.test(match)) for white spaces\n \nreturn index === 0 ? match.toLowerCase() : match.toUpperCase()\n })\n }\n\n String.prototype.truncate = function (len: number = 20, suffix: string = '...') {\n if (this.length <= len) {\n return this.toString()\n }\n\n const truncated = this.substring(0, len)\n const lastSpaceIndex = truncated.lastIndexOf(' ')\n if (lastSpaceIndex > 0) {\n return truncated.substring(0, lastSpaceIndex) + suffix\n }\n \nreturn truncated + suffix\n }\n} \n"],"mappings":";;;AAAA,MAAa,wBAAwB,aAAyC;AAC5E;EAAC;EAAU;EAAW;EAAU,CAAC,SAAS,WAAW;AACnD,UAAQ,GAAG,QAAQ,YAAY;AAC7B,SAAM,UAAU;IAChB;GACF;;;;;ACHJ,MAAa,uBAAuB,OAClC,MACA,gBAAwB,QACrB;AAEH,OAAM,KADO,MAAM,OAAO,cAAc,CACxB;;AAIlB,MAAa,0BAA0B,EACrC,UAAU,iCACV,OACA,OACA,OAAO,UAMH;AAYJ,SAXyC;EACvC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACN,CAEgB,SAAS,SAAS;AAEnC,QAAO;;;iBAGQ,KAAK,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;cA0BnB,KAAK;cACL,MAAM;aACP,QAAQ;UACX,QAAQ,6BAA6B,MAAM,UAAU,GAAG;;;;;;;;ACnElE,MAAa,uBAAuB;AAChC,QAAO,UAAU,YAAY,WAAY;AACrC,SAAO,KAAK,aAAa,CACpB,QAAQ,MAAM,IAAI,CAClB,QAAQ,MAAM,IAAI,CAClB,QAAQ,eAAe,SAAU,OAAO;AACrC,UAAO,MAAM,aAAa;IAC5B;;AAGV,QAAO,UAAU,YAAY,WAAY;AACrC,SAAO,KAAK,QAAQ,2BAA2B,SAAU,OAAO,OAAO;AACnE,OAAI,CAAC,UAAU,EAAG,QAAO;AAErC,UAAO,UAAU,IAAI,MAAM,aAAa,GAAG,MAAM,aAAa;IACpD;;AAGN,QAAO,UAAU,WAAW,SAAU,MAAc,IAAI,SAAiB,OAAO;AAC5E,MAAI,KAAK,UAAU,IACf,QAAO,KAAK,UAAU;EAG1B,MAAM,YAAY,KAAK,UAAU,GAAG,IAAI;EACxC,MAAM,iBAAiB,UAAU,YAAY,IAAI;AACjD,MAAI,iBAAiB,EACjB,QAAO,UAAU,UAAU,GAAG,eAAe,GAAG;AAG5D,SAAO,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/common",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Common package for Arkstack providing common implementations of core Arkstack features such as routing, middleware, and database integration.",
|
|
6
|
+
"homepage": "https://arkstack.toneflix.net",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/arkstack-hq/arkstack.git",
|