@joystick.js/node-canary 0.0.0-canary.425 → 0.0.0-canary.427

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/index.js CHANGED
@@ -1 +1 @@
1
- import m from"./api/accounts/authenticated.js";import h from"./api/accounts/login.js";import g from"./api/accounts/logout.js";import f from"./api/accounts/recover_password.js";import d from"./api/accounts/reset_password.js";import l from"./api/accounts/signup.js";import b from"./api/accounts/user.js";import x from"./api/accounts/verify_email.js";import j from"./api/push/health.js";import w from"./api/test/accounts/delete.js";import y from"./api/test/accounts/signup.js";import q from"./api/test/bootstrap.js";import v from"./api/test/process.js";import O from"./api/test/queues.js";import k from"./databases/mongodb/create_indexes.js";import R from"./databases/postgresql/create_indexes.js";import E from"./databases/postgresql/create_tables.js";import N from"./generate_machine_id.js";import D from"./generate_process_id.js";import _ from"./databases/get_target_database_connection.js";import I from"./handle_process_errors.js";import J from"./settings/load.js";import A from"./queues/index.js";import B from"./register_app_options.js";import L from"./cron_jobs/register.js";import P from"./databases/register_database.js";import S from"./api/register_getters.js";import U from"./routes/register_route_from_function.js";import Q from"./routes/register_route_from_object.js";import T from"./api/register_setters.js";import V from"./uploaders/register.js";import $ from"./websockets/register.js";import z from"./start_express.js";import C from"./start_node_as_cluster.js";import p from"../lib/types.js";const F=J();class G{constructor(t={}){I(t?.events),B(this,t),this.generate_machine_id(),this.generate_process_id(),process.title=process.env.NODE_ENV==="test"?"joystick_test_app":"joystick_app",process.joystick={app_options:t}}async connect_databases(){const t=F?.config?.databases;for(let s=0;s<t?.length;s+=1){const e=t[s],r=parseInt(process.env.PORT,10)+10+s,a=t?.filter(n=>e?.provider===n?.provider)?.length>1;await P(e,r,a)}if(t?.length>0){const s=_("queues"),e=_("sessions"),r=_("users");process.databases._queues=s?.connection,process.databases._sessions=e?.connection,process.databases._users=r?.connection;const a=[s,e,r],n=a?.filter(i=>i?.provider==="mongodb")?.map(i=>i?.database_type);await k(n);const c=a?.filter(i=>i?.provider==="postgresql")?.map(i=>i?.database_type);await E(c),await R(c)}}async generate_machine_id(){this.joystick_machine_id=await N()}async generate_process_id(){this.joystick_process_id=await D()}on_after_start_server(t={}){process.on("message",s=>{typeof s=="string"&&JSON.parse(s)?.type==="BUILD_ERROR"&&(process.BUILD_ERROR=JSON.parse(s))}),console.log(`App running at: http://localhost:${t.port}`)}register_accounts(){this.express.app.get("/api/_accounts/authenticated",m),this.express.app.post("/api/_accounts/user",b),this.express.app.post("/api/_accounts/login",h),this.express.app.post("/api/_accounts/logout",g),this.express.app.post("/api/_accounts/recover-password",f),this.express.app.post("/api/_accounts/reset-password",d),this.express.app.post("/api/_accounts/signup",l),this.express.app.post("/api/_accounts/verify-email",x)}register_api(){const t=this?.options?.api?.getters,s=this?.options?.api?.setters,e=this?.options?.api?.options,r=this?.options?.api?.context;t&&p.is_object(t)&&Object.keys(t||{}).length>0&&S(this.express.app,Object.entries(t||{}),r,e),s&&p.is_object(s)&&Object.keys(s||{}).length>0&&T(this.express.app,Object.entries(s||{}),r,e)}register_cron_jobs(){L(this.options.cronJobs||this.options.cron_jobs)}register_fixtures(){p.is_function(this.options.fixtures)&&this.options.fixtures()}register_indexes(){p.is_function(this.options.indexes)&&this.options.indexes()}register_push(){this.express.app.get("/api/_push/health",j)}register_queues(){if(p.is_object(this.options.queues)){const t=Object.entries(this.options.queues||{});for(let s=0;s<t.length;s+=1){const[e,r]=t[s];process.queues={...process.queues||{},[e]:new A(e,r)}}}}register_routes(){const t=Object.entries(this?.options?.routes||{});for(let s=0;s<t?.length;s+=1){const[e,r]=t[s],a=p.is_object(r);p.is_function(r)&&U(this.express.app,e,r),a&&Q(this.express.app,e,r)}}register_tests(){this.express.app.get("/api/_test/bootstrap",(t={},s={})=>q(t,s,this)),this.express.app.get("/api/_test/process",v),this.express.app.delete("/api/_test/accounts",w),this.express.app.post("/api/_test/accounts/signup",y),this.express.app.post("/api/_test/queues",(t={},s={})=>O(t,s,this))}register_uploaders(){V(this.options.uploaders,this)}register_websockets(){$(this.options.websockets,this)}async start(){await this.connect_databases(),this.register_cron_jobs(),this.register_queues(),this.start_express(),this.register_tests(),this.register_accounts(),this.register_api(),this.register_routes(),this.register_websockets(),this.register_uploaders(),this.register_push(),this.register_fixtures(),this.register_indexes()}start_express(){this.express=z(this.on_after_start_server,this)}}const u=async(o={})=>{const t=new G(o);return await t.start(o),t},H=(o={})=>new Promise(async t=>{if(o?.cluster)C(async()=>{const s=await u(o);return t(s.express)});else{const s=await u(o);return t(s.express)}});var Ns=H;export{Ns as default};
1
+ import m from"./api/accounts/authenticated.js";import h from"./api/accounts/login.js";import g from"./api/accounts/logout.js";import f from"./api/accounts/recover_password.js";import d from"./api/accounts/reset_password.js";import l from"./api/accounts/signup.js";import b from"./api/accounts/user.js";import x from"./api/accounts/verify_email.js";import j from"./api/push/health.js";import w from"./api/test/accounts/delete.js";import y from"./api/test/accounts/signup.js";import q from"./api/test/bootstrap.js";import v from"./api/test/process.js";import O from"./api/test/queues.js";import k from"./databases/mongodb/create_indexes.js";import R from"./databases/postgresql/create_indexes.js";import E from"./databases/postgresql/create_tables.js";import N from"./generate_machine_id.js";import D from"./generate_process_id.js";import _ from"./databases/get_target_database_connection.js";import I from"./handle_process_errors.js";import J from"./settings/load.js";import A from"./queues/index.js";import B from"./register_app_options.js";import L from"./cron_jobs/register.js";import P from"./databases/register_database.js";import S from"./api/register_getters.js";import U from"./routes/register_route_from_function.js";import Q from"./routes/register_route_from_object.js";import T from"./api/register_setters.js";import V from"./uploaders/register.js";import $ from"./websockets/register.js";import z from"./start_express.js";import C from"./start_node_as_cluster.js";import p from"../lib/types.js";import F from"./push_logs.js";const G=J();F();class H{constructor(t={}){I(t?.events),B(this,t),this.generate_machine_id(),this.generate_process_id(),process.title=process.env.NODE_ENV==="test"?"joystick_test_app":"joystick_app",process.joystick={app_options:t}}async connect_databases(){const t=G?.config?.databases;for(let s=0;s<t?.length;s+=1){const e=t[s],r=parseInt(process.env.PORT,10)+10+s,a=t?.filter(n=>e?.provider===n?.provider)?.length>1;await P(e,r,a)}if(t?.length>0){const s=_("queues"),e=_("sessions"),r=_("users");process.databases._queues=s?.connection,process.databases._sessions=e?.connection,process.databases._users=r?.connection;const a=[s,e,r],n=a?.filter(i=>i?.provider==="mongodb")?.map(i=>i?.database_type);await k(n);const c=a?.filter(i=>i?.provider==="postgresql")?.map(i=>i?.database_type);await E(c),await R(c)}}async generate_machine_id(){this.joystick_machine_id=await N()}async generate_process_id(){this.joystick_process_id=await D()}on_after_start_server(t={}){process.on("message",s=>{typeof s=="string"&&JSON.parse(s)?.type==="BUILD_ERROR"&&(process.BUILD_ERROR=JSON.parse(s))}),console.log(`App running at: http://localhost:${t.port}`)}register_accounts(){this.express.app.get("/api/_accounts/authenticated",m),this.express.app.post("/api/_accounts/user",b),this.express.app.post("/api/_accounts/login",h),this.express.app.post("/api/_accounts/logout",g),this.express.app.post("/api/_accounts/recover-password",f),this.express.app.post("/api/_accounts/reset-password",d),this.express.app.post("/api/_accounts/signup",l),this.express.app.post("/api/_accounts/verify-email",x)}register_api(){const t=this?.options?.api?.getters,s=this?.options?.api?.setters,e=this?.options?.api?.options,r=this?.options?.api?.context;t&&p.is_object(t)&&Object.keys(t||{}).length>0&&S(this.express.app,Object.entries(t||{}),r,e),s&&p.is_object(s)&&Object.keys(s||{}).length>0&&T(this.express.app,Object.entries(s||{}),r,e)}register_cron_jobs(){L(this.options.cronJobs||this.options.cron_jobs)}register_fixtures(){p.is_function(this.options.fixtures)&&this.options.fixtures()}register_indexes(){p.is_function(this.options.indexes)&&this.options.indexes()}register_push(){this.express.app.get("/api/_push/health",j)}register_queues(){if(p.is_object(this.options.queues)){const t=Object.entries(this.options.queues||{});for(let s=0;s<t.length;s+=1){const[e,r]=t[s];process.queues={...process.queues||{},[e]:new A(e,r)}}}}register_routes(){const t=Object.entries(this?.options?.routes||{});for(let s=0;s<t?.length;s+=1){const[e,r]=t[s],a=p.is_object(r);p.is_function(r)&&U(this.express.app,e,r),a&&Q(this.express.app,e,r)}}register_tests(){this.express.app.get("/api/_test/bootstrap",(t={},s={})=>q(t,s,this)),this.express.app.get("/api/_test/process",v),this.express.app.delete("/api/_test/accounts",w),this.express.app.post("/api/_test/accounts/signup",y),this.express.app.post("/api/_test/queues",(t={},s={})=>O(t,s,this))}register_uploaders(){V(this.options.uploaders,this)}register_websockets(){$(this.options.websockets,this)}async start(){await this.connect_databases(),this.register_cron_jobs(),this.register_queues(),this.start_express(),this.register_tests(),this.register_accounts(),this.register_api(),this.register_routes(),this.register_websockets(),this.register_uploaders(),this.register_push(),this.register_fixtures(),this.register_indexes()}start_express(){this.express=z(this.on_after_start_server,this)}}const u=async(o={})=>{const t=new H(o);return await t.start(o),t},K=(o={})=>new Promise(async t=>{if(o?.cluster)C(async()=>{const s=await u(o);return t(s.express)});else{const s=await u(o);return t(s.express)}});var Is=K;export{Is as default};
@@ -1 +1 @@
1
- import t from"winston";import r from"fs";import e from"../lib/path_exists.js";const{mkdir:i}=r.promises,a=async()=>{await e("push/logs")||await i("push/logs",{recursive:!0});const s=t.createLogger({format:t.format.combine(t.format.timestamp(),t.format.json()),transports:[new t.transports.File({filename:"push/logs/app.log",maxsize:1024*1024*20,maxFiles:1,tailable:!0})]});process.stdout.write=o=>{s.debug(o)},process.stderr.write=o=>{s.error(o)},process.on("uncaughtException",o=>{s.error(o instanceof Error?o?.toString():o)}),process.on("unhandledRejection",o=>{s.error(o instanceof Error?o?.toString():o)})};var c=a;export{c as default};
1
+ import s from"winston";import r from"fs";import e from"../lib/path_exists.js";const{mkdir:n}=r.promises,i=async()=>{await e("push/logs")||await n("push/logs",{recursive:!0});const t=s.createLogger({format:s.format.combine(s.format.timestamp(),s.format.json()),transports:[new s.transports.File({filename:"push/logs/app.log",maxsize:1024*1024*20,maxFiles:1,tailable:!0})]});process.stdout.write=o=>{console.log(o),t.debug(o)},process.stderr.write=o=>{console.log(o),t.error(o)},process.on("uncaughtException",o=>{t.error(o instanceof Error?o?.toString():o)}),process.on("unhandledRejection",o=>{t.error(o instanceof Error?o?.toString():o)})};var m=i;export{m as default};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import s from"fs";import t from"./app/accounts/index.js";import i from"./action/index.js";import n from"./lib/escape_html.js";import p from"./app/fixture/index.js";import a from"./app/databases/sql.js";import m from"./app/api/validate_input.js";import c from"./app/websockets/index.js";import l from"./app/index.js";import _ from"./lib/generate_id.js";import f from"./lib/get_origin.js";import u from"./app/settings/load.js";import d from"./lib/node_path_polyfills.js";import o from"./lib/path_exists.js";import x from"./app/email/send.js";import w from"./app/push_logs.js";const{readFile:e}=s.promises;w();const h={...t,deleteUser:t.delete_user,recoverPassword:t.recover_password,resetPassword:t.reset_password,sendEmailVerification:t.send_email_verification,setPassword:t.set_password,verifyEmail:t.verify_email},v=i,g={send:x},k=n,y=p,b=f(),P={continent:await o("/root/push/continent.txt")?(await e("/root/push/continent.txt","utf-8"))?.replace(`
1
+ import s from"fs";import t from"./app/accounts/index.js";import i from"./action/index.js";import n from"./lib/escape_html.js";import a from"./app/fixture/index.js";import p from"./app/databases/sql.js";import c from"./app/api/validate_input.js";import m from"./app/websockets/index.js";import l from"./app/index.js";import _ from"./lib/generate_id.js";import f from"./lib/get_origin.js";import u from"./app/settings/load.js";import d from"./lib/node_path_polyfills.js";import o from"./lib/path_exists.js";import x from"./app/email/send.js";const{readFile:e}=s.promises,w={...t,deleteUser:t.delete_user,recoverPassword:t.recover_password,resetPassword:t.reset_password,sendEmailVerification:t.send_email_verification,setPassword:t.set_password,verifyEmail:t.verify_email},h=i,v={send:x},g=n,k=a,y=f(),b={continent:await o("/root/push/continent.txt")?(await e("/root/push/continent.txt","utf-8"))?.replace(`
2
2
  `,""):null,instance_token:await o("/root/push/instance_token.txt")?(await e("/root/push/instance_token.txt","utf-8"))?.replace(`
3
3
  `,""):null,current_version:await o("/root/push/versions/current")?(await e("/root/push/versions/current","utf-8"))?.replace(`
4
- `,""):null},j=u(),q=a,E=m,F=c,r={app:l,accounts:h,action:v,email:g,emitters:{},escape_html:k,fixture:y,id:_,origin:b,push:P,settings:j,sql:q,validate_input:E,websockets:F,...d};global.joystick=r;var Q=r;export{h as accounts,v as action,Q as default,g as email,k as escape_html,y as fixture,b as origin,P as push,j as settings,q as sql,E as validate_input,F as websockets};
4
+ `,""):null},P=u(),j=p,q=c,E=m,r={app:l,accounts:w,action:h,email:v,emitters:{},escape_html:g,fixture:k,id:_,origin:y,push:b,settings:P,sql:j,validate_input:q,websockets:E,...d};global.joystick=r;var N=r;export{w as accounts,h as action,N as default,v as email,g as escape_html,k as fixture,y as origin,b as push,P as settings,j as sql,q as validate_input,E as websockets};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.425",
4
+ "version": "0.0.0-canary.427",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
package/src/app/index.js CHANGED
@@ -33,9 +33,14 @@ import register_websockets from "./websockets/register.js";
33
33
  import start_express from "./start_express.js";
34
34
  import start_node_as_cluster from "./start_node_as_cluster.js";
35
35
  import types from "../lib/types.js";
36
+ import push_logs from "./push_logs.js";
36
37
 
37
38
  const app_settings = load_settings();
38
39
 
40
+ // if (process.env.NODE_ENV !== "development" && process.env.IS_PUSH_DEPLOYED) {
41
+ push_logs();
42
+ // }
43
+
39
44
  class App {
40
45
  constructor(app_options = {}) {
41
46
  handle_process_errors(app_options?.events);
@@ -25,10 +25,12 @@ const push_logs = async () => {
25
25
  });
26
26
 
27
27
  process.stdout.write = (data) => {
28
+ console.log(data);
28
29
  logger.debug(data);
29
30
  };
30
31
 
31
32
  process.stderr.write = (data) => {
33
+ console.log(data);
32
34
  logger.error(data);
33
35
  };
34
36
 
package/src/index.js CHANGED
@@ -13,14 +13,9 @@ import load_settings from './app/settings/load.js';
13
13
  import node_path_polyfills from './lib/node_path_polyfills.js';
14
14
  import path_exists from './lib/path_exists.js';
15
15
  import send_email from './app/email/send.js';
16
- import push_logs from './app/push_logs.js';
17
16
 
18
17
  const { readFile } = fs.promises;
19
18
 
20
- // if (process.env.NODE_ENV !== "development" && process.env.IS_PUSH_DEPLOYED) {
21
- push_logs();
22
- // }
23
-
24
19
  // NOTE: Ensure backwards compatibility for existing apps by offering
25
20
  // original camelCase versions of methods.
26
21
  export const accounts = {