@@ -10,8 +10,16 @@ import mongoose from 'mongoose';
1010
1111import AuthService from '../../auth/services/auth.service.js' ;
1212import config from '../../../config/index.js' ;
13+ import mailer from '../../../lib/helpers/mailer/index.js' ;
1314import HomeRepository from '../repositories/home.repository.js' ;
1415
16+ /**
17+ * @desc Check whether a config value is meaningfully set (truthy, non-empty, not a DEVKIT placeholder).
18+ * @param {* } value - Config value to check
19+ * @returns {boolean } true if set and not a placeholder
20+ */
21+ const isSet = ( value ) => ! ! ( value && typeof value === 'string' && value . trim ( ) !== '' && ! value . startsWith ( 'DEVKIT_NODE_' ) ) ;
22+
1523/**
1624 * @desc Function to get all admin users in db
1725 * @return {Promise } All users
@@ -102,10 +110,80 @@ const getHealthStatus = () => {
102110 } ;
103111} ;
104112
113+ /**
114+ * @desc Run SaaS readiness checks against current configuration.
115+ * Each check returns { category, status, message }.
116+ * @returns {Array<{category: string, status: string, message: string}> }
117+ */
118+ const getReadinessStatus = ( ) => {
119+ const checks = [ ] ;
120+
121+ // config — domain
122+ checks . push ( {
123+ category : 'config' ,
124+ status : isSet ( config . domain ) ? 'ok' : 'warning' ,
125+ message : isSet ( config . domain ) ? 'Domain configured' : 'Domain not configured' ,
126+ } ) ;
127+
128+ // security — JWT secret
129+ const jwtDefault = config . jwt ?. secret === 'WaosSecretKeyExampleToChnageAbsolutely' ;
130+ checks . push ( {
131+ category : 'security' ,
132+ status : jwtDefault ? 'warning' : 'ok' ,
133+ message : jwtDefault ? 'JWT secret is default — change it before production' : 'JWT secret is custom' ,
134+ } ) ;
135+
136+ // auth — OAuth providers
137+ const oAuthProviders = [ ] ;
138+ if ( isSet ( config . oAuth ?. google ?. clientID ) ) oAuthProviders . push ( 'Google' ) ;
139+ if ( isSet ( config . oAuth ?. apple ?. clientID ) ) oAuthProviders . push ( 'Apple' ) ;
140+ checks . push ( {
141+ category : 'auth' ,
142+ status : oAuthProviders . length > 0 ? 'ok' : 'warning' ,
143+ message : oAuthProviders . length > 0 ? `OAuth configured (${ oAuthProviders . join ( ', ' ) } )` : 'No OAuth provider configured' ,
144+ } ) ;
145+
146+ // mail — mailer from
147+ const mailConfigured = mailer . isConfigured ( ) ;
148+ const mailProvider = config . mailer ?. provider || 'nodemailer' ;
149+ checks . push ( {
150+ category : 'mail' ,
151+ status : mailConfigured ? 'ok' : 'warning' ,
152+ message : mailConfigured ? `Mail configured (${ mailProvider } )` : 'No mail provider configured' ,
153+ } ) ;
154+
155+ // billing — Stripe
156+ const stripeConfigured = isSet ( config . stripe ?. secretKey ) ;
157+ checks . push ( {
158+ category : 'billing' ,
159+ status : stripeConfigured ? 'ok' : 'warning' ,
160+ message : stripeConfigured ? 'Stripe configured' : 'Stripe not configured' ,
161+ } ) ;
162+
163+ // analytics — PostHog
164+ const posthogConfigured = isSet ( config . posthog ?. apiKey ) ;
165+ checks . push ( {
166+ category : 'analytics' ,
167+ status : posthogConfigured ? 'ok' : 'warning' ,
168+ message : posthogConfigured ? 'PostHog configured' : 'PostHog not configured' ,
169+ } ) ;
170+
171+ // monitoring — Sentry
172+ const sentryConfigured = isSet ( config . sentry ?. dsn ) ;
173+ checks . push ( {
174+ category : 'monitoring' ,
175+ status : sentryConfigured ? 'ok' : 'warning' ,
176+ message : sentryConfigured ? 'Sentry configured' : 'Sentry not configured' ,
177+ } ) ;
178+
179+ return checks ;
180+ } ;
181+
105182export default {
106183 page,
107184 releases,
108185 changelogs,
109186 team,
110187 getHealthStatus,
188+ getReadinessStatus,
111189} ;
0 commit comments