Skip to content

Commit

Permalink
update siteConfigSetEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
ceddybi committed Apr 13, 2024
1 parent c4c5b9c commit 650bdef
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 89 deletions.
93 changes: 93 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import 'cross-fetch/polyfill';
import "reflect-metadata";
import "dotenv/config";

import { OrderRatingResolver, OrderResolver } from './order';
import { RoadmanBuild, log, roadman } from "roadman";
import {
TransactionDefaultResolver,
btcpayserverRoadman,
getWalletResolvers,
moneroserverRoadman,
} from "@roadmanjs/wallet";
import { WithdrawRequestAdminResolver, WithdrawRequestResolver } from './withdrawRequest';
import { get as _get, isEmpty } from "lodash";

import AdCategoryResolver from "./listing/AdCategory.resolver";
import { AdsListingResolver } from './listing/AdsListing.model';
import { BadgeResolver } from './badge/Badge.resolver';
import CountryResolver from './country/Country.resolver';
import { NotificationResolver } from './notification';
import PgpResolver from './auth/Pgp.resolver';
import SettingsResolver from './settings/settings.resolver';
import UserAuthPwResolver from './auth/User.resolver.pw';
import UserAuthResolver from './auth/User.resolver.auth';
import VendorResolver from './vendor/vendor.resolver';
import { couchsetRoadman } from "@roadmanjs/couchset";
import { createDefaultIndexes } from './_startup';
import { getAdListingResolvers } from "./listing";
import { getAuthResolvers } from "@roadmanjs/auth";
import { getChatResolvers } from "@roadmanjs/chat";
import { getSocialResolvers } from "@roadmanjs/social";
import { mediaRoadman } from './media/media.app';
import { DisputeAdminResolver, DisputesResolver } from './disputes';
import AdminSettingsResolver from './settings/settings.resolver.admin';
import { initSiteSettings } from './_config/site';
import { getSiteSettings } from './settings/settings.methods';

const resolvers = [
...getAuthResolvers(),
...getChatResolvers(),
...getSocialResolvers(),
...getWalletResolvers(),
...getAdListingResolvers(),
AdsListingResolver,
OrderResolver,
OrderRatingResolver,
WithdrawRequestResolver,
WithdrawRequestAdminResolver,
AdCategoryResolver,
CountryResolver,
VendorResolver,
SettingsResolver,
AdminSettingsResolver,
TransactionDefaultResolver,
PgpResolver, UserAuthResolver, UserAuthPwResolver, NotificationResolver, BadgeResolver, DisputeAdminResolver, DisputesResolver
];

const app = async (args: RoadmanBuild): Promise<RoadmanBuild> => {
const { app } = args;

app.get("/client/settings", async (req, res) => {
const siteSettings = await getSiteSettings(true);
const settings = siteSettings ? siteSettings : initSiteSettings;
res.json(settings);
});

return args;
}

const run = async () => {

const roadmanStarted = await roadman({
roadmen: [
app,
mediaRoadman,
couchsetRoadman,
btcpayserverRoadman, moneroserverRoadman,
],
resolvers,
});

if (roadmanStarted) {
if (!isEmpty(process.env.STARTUP)) {
log("startup", "running startup");
setTimeout(async () => {
log("roadmanStarted", roadmanStarted);
await createDefaultIndexes();
}, 3000);
}
}
};

run();
90 changes: 4 additions & 86 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,12 @@ import 'cross-fetch/polyfill';
import "reflect-metadata";
import "dotenv/config";

import { OrderRatingResolver, OrderResolver } from './order';
import { RoadmanBuild, log, roadman } from "roadman";
import {
TransactionDefaultResolver,
btcpayserverRoadman,
getWalletResolvers,
moneroserverRoadman,
} from "@roadmanjs/wallet";
import { WithdrawRequestAdminResolver, WithdrawRequestResolver } from './withdrawRequest';
import { get as _get, isEmpty } from "lodash";

import AdCategoryResolver from "./listing/AdCategory.resolver";
import { AdsListingResolver } from './listing/AdsListing.model';
import { BadgeResolver } from './badge/Badge.resolver';
import CountryResolver from './country/Country.resolver';
import { NotificationResolver } from './notification';
import PgpResolver from './auth/Pgp.resolver';
import SettingsResolver from './settings/settings.resolver';
import UserAuthPwResolver from './auth/User.resolver.pw';
import UserAuthResolver from './auth/User.resolver.auth';
import VendorResolver from './vendor/vendor.resolver';
import { couchsetRoadman } from "@roadmanjs/couchset";
import { createDefaultIndexes } from './_startup';
import { getAdListingResolvers } from "./listing";
import { getAuthResolvers } from "@roadmanjs/auth";
import { getChatResolvers } from "@roadmanjs/chat";
import { getSocialResolvers } from "@roadmanjs/social";
import { mediaRoadman } from './media/media.app';
import { DisputeAdminResolver, DisputesResolver } from './disputes';
import AdminSettingsResolver from './settings/settings.resolver.admin';
import { initSiteSettings } from './_config/site';
import { getSiteSettings, initConfigSiteSettings } from './settings/settings.methods';

const resolvers = [
...getAuthResolvers(),
...getChatResolvers(),
...getSocialResolvers(),
...getWalletResolvers(),
...getAdListingResolvers(),
AdsListingResolver,
OrderResolver,
OrderRatingResolver,
WithdrawRequestResolver,
WithdrawRequestAdminResolver,
AdCategoryResolver,
CountryResolver,
VendorResolver,
SettingsResolver,
AdminSettingsResolver,
TransactionDefaultResolver,
PgpResolver, UserAuthResolver, UserAuthPwResolver, NotificationResolver, BadgeResolver, DisputeAdminResolver, DisputesResolver
];

const app = async (args: RoadmanBuild): Promise<RoadmanBuild> => {
const { app } = args;

app.get("/client/settings", async (req, res) => {
const siteSettings = await getSiteSettings(true);
const settings = siteSettings ? siteSettings : initSiteSettings;
res.json(settings);
});

return args;
}
import { get as _get } from "lodash";
import { siteConfigSetEnv } from './settings/settings.methods';

const run = async () => {

await initConfigSiteSettings();

const roadmanStarted = await roadman({
roadmen: [
app,
mediaRoadman,
couchsetRoadman,
btcpayserverRoadman, moneroserverRoadman,
],
resolvers,
});

if (roadmanStarted) {
if (!isEmpty(process.env.STARTUP)) {
log("startup", "running startup");
setTimeout(async () => {
log("roadmanStarted", roadmanStarted);
await createDefaultIndexes();
}, 3000);
}
}
await siteConfigSetEnv();
await import("./app");
};

run();
4 changes: 2 additions & 2 deletions src/monerox.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "dotenv/config";
import { Query, Resolver } from 'type-graphql';
import { RoadmanBuild, roadman, log } from "roadman";
import { walletRouter as moneroxWalletRouter, listenMain } from "@roadmanjs/monerox";
import { initConfigSiteSettings } from "./settings/settings.methods";
import { siteConfigSetEnv } from "./settings/settings.methods";

@Resolver()
class ExampleResolver {
Expand All @@ -25,7 +25,7 @@ const customRoadmanApp = async (args: RoadmanBuild): Promise<RoadmanBuild> => {

const run = async () => {

await initConfigSiteSettings();
await siteConfigSetEnv();

const roadmanStarted = await roadman({
roadmen: [
Expand Down
2 changes: 1 addition & 1 deletion src/settings/settings.methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ siteStatsQueue.process(async (job, done) => {
done();
});

export const initConfigSiteSettings = async () => {
export const siteConfigSetEnv = async () => {
await couchsetRoadman(null as any);
const siteSettings = await getSiteSettings();
if (siteSettings) {
Expand Down

0 comments on commit 650bdef

Please sign in to comment.