@@ -5,36 +5,37 @@ import { container } from 'tsyringe';
5
5
import { IamController } from './controllers/iam.controller' ;
6
6
import { env } from './configs/envs.config' ;
7
7
import { validateAuthSession , verifyOrigin } from './middlewares/auth.middleware' ;
8
- // import { TestJob } from './jobs/test.job';
9
- import { glob , globSync } from 'glob' ;
10
- import path from 'path' ;
8
+ import { AuthCleanupJobs } from './jobs/auth-cleanup.job' ;
11
9
12
- console . log ( 'API SERVER STARTED' ) ;
13
- /* ----------------------------------- Api ---------------------------------- */
14
- const app = new Hono ( ) . basePath ( '/api' ) ;
10
+ /* -------------------------------------------------------------------------- */
11
+ /* App */
12
+ /* -------------------------------------------------------------------------- */
13
+ export const app = new Hono ( ) . basePath ( '/api' ) ;
15
14
16
- /* --------------------------- Global Middlewares --------------------------- */
15
+ /* -------------------------------------------------------------------------- */
16
+ /* Global Middlewares */
17
+ /* -------------------------------------------------------------------------- */
17
18
app . use ( verifyOrigin ) . use ( validateAuthSession ) ;
18
19
19
- /* --------------------------------- Routes --------------------------------- */
20
+ /* -------------------------------------------------------------------------- */
21
+ /* Routes */
22
+ /* -------------------------------------------------------------------------- */
20
23
const routes = app
21
24
. route ( '/iam' , container . resolve ( IamController ) . routes ( ) )
22
25
26
+ /* -------------------------------------------------------------------------- */
27
+ /* Cron Jobs */
28
+ /* -------------------------------------------------------------------------- */
29
+ container . resolve ( AuthCleanupJobs ) . deleteStaleEmailVerificationRequests ( ) ;
30
+ container . resolve ( AuthCleanupJobs ) . deleteStaleLoginRequests ( ) ;
31
+
23
32
/* -------------------------------------------------------------------------- */
24
33
/* Exports */
25
34
/* -------------------------------------------------------------------------- */
26
- export const rpc = hc < typeof routes > ( env . ORIGIN ) ;
35
+ const rpc = hc < typeof routes > ( env . ORIGIN ) ;
27
36
export type ApiClient = typeof rpc ;
28
37
export type ApiRoutes = typeof routes ;
29
- export { app } ;
30
38
31
- async function resolveJobs ( ) {
32
- const jobFiles = globSync ( '**/*.job.*' ) ;
33
39
34
- for ( const file of jobFiles ) {
35
- const module = await import ( path . resolve ( file ) ) ;
36
- container . resolve ( module . default )
37
- }
38
- }
39
40
40
- resolveJobs ( ) ;
41
+
0 commit comments