Skip to content

Commit

Permalink
🔄 synced local 'src/' with remote 'src/'
Browse files Browse the repository at this point in the history
  • Loading branch information
circle-github-action-bot committed May 2, 2024
1 parent 0182d44 commit 341912f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
24 changes: 9 additions & 15 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ import {
} from './routers';

export const app: Express = express();
const parentRouter = express.Router();

app.use(cors());
app.use(express.json());

parentRouter.get('/', (_req: Request, res: Response) => {
app.get('/', (_req: Request, res: Response) => {
res.send('Sample Server');
});

/**
* Health check endpoint.
*/
parentRouter.get('/ping', (_req: Request, res: Response) => {
app.get('/ping', (_req: Request, res: Response) => {
res.status(200).send('pong');
});

Expand All @@ -47,7 +46,7 @@ parentRouter.get('/ping', (_req: Request, res: Response) => {
* encryptionKey: string - encryption key to use to execute challengeIds
* challengeId: string - used to initiate a challenge flow to setup PIN + Wallet
*/
parentRouter.post('/signup', validate(authenticationSchema), signUp);
app.post('/signup', validate(authenticationSchema), signUp);

/**
* POST - /signIn
Expand All @@ -67,20 +66,15 @@ parentRouter.post('/signup', validate(authenticationSchema), signUp);
* If user credentials wrong or don't exist:
* returns 404
*/
parentRouter.post('/signin', validate(authenticationSchema), signIn);
app.post('/signin', validate(authenticationSchema), signIn);

/*
* Add all sub paths to the parent router
* Add all sub paths
*/
parentRouter.use('/users', usersRouter, authUserRouter);
parentRouter.use('/tokens', tokensRouter);
parentRouter.use('/wallets', authMiddleware, walletsRouter);
parentRouter.use('/transactions', transactionsRouter, authTransRouter);

/*
* Add the parent router with ALL paths to the main app
*/
app.use('/pw-user-controlled/foundational', parentRouter);
app.use('/users', usersRouter, authUserRouter);
app.use('/tokens', tokensRouter);
app.use('/wallets', authMiddleware, walletsRouter);
app.use('/transactions', transactionsRouter, authTransRouter);

// Error handling
app.use(errorHandler);
1 change: 0 additions & 1 deletion src/controllers/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const createTransaction = async (

const response = await circleUserSdk.createTransaction({
userToken: req.headers['token'] as string,
// Yup validation in the middleware allows the spread of the req.body valid.
fee: feeConfig,
idempotencyKey: req.body.idempotencyKey,
refId: req.body.refId,
Expand Down
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ initDB();

const port = process.env.PORT ?? 8080;
const server = app.listen(port, () => {
logger.info(
`Server is running at http://localhost:${port}/pw-user-controlled/foundational`
);
logger.info(`Server is running at http://localhost:${port}`);
});

process.on('SIGINT', function () {
Expand Down

0 comments on commit 341912f

Please sign in to comment.