feat: verify hostname (load free certificate call to bunny cdn) (#271)
* feat: initialize the handler and function. * feat: add call to the bunny cdn api. * refactor: rename access points to apps. * refactor: remove redundant catch and throw Co-authored-by: Felipe Mendes <zo.fmendes@gmail.com> --------- Co-authored-by: Felipe Mendes <zo.fmendes@gmail.com>
This commit is contained in:
parent
12df937d17
commit
94313c0300
|
|
@ -92,4 +92,12 @@ functions:
|
|||
layers:
|
||||
- { Ref: TopicAwsNodeModulesLambdaLayer }
|
||||
- { Ref: TopicAwsLibsLambdaLayer }
|
||||
- { Ref: TopicPrismaAwsPrismaClientLambdaLayer }
|
||||
- { Ref: TopicPrismaAwsPrismaClientLambdaLayer }
|
||||
|
||||
verifyAccessPoint:
|
||||
handler: src/functions/apps/handler.verifyApp
|
||||
events:
|
||||
- http:
|
||||
path: verifyApp
|
||||
method: post
|
||||
cors: true
|
||||
|
|
@ -7,8 +7,43 @@ import {
|
|||
BunnyCdn,
|
||||
BunnyCdnError,
|
||||
CreatePullZoneMethodArgs,
|
||||
LoadFreeCertificateMethodArgs,
|
||||
} from '@libs/bunnyCDN';
|
||||
|
||||
export const verifyApp = async (
|
||||
event: APIGatewayEvent
|
||||
): Promise<APIGatewayProxyResult> => {
|
||||
try {
|
||||
// Check the parameters and environment variables
|
||||
dotenv.config();
|
||||
if (event.body === null || process.env.BUNNY_CDN_ACCESS_KEY == undefined) {
|
||||
return formatJSONResponse({
|
||||
status: 422,
|
||||
message: 'Required parameters were not passed.',
|
||||
});
|
||||
}
|
||||
|
||||
// Set up constants
|
||||
const bunnyCdn = new BunnyCdn(process.env.BUNNY_CDN_ACCESS_KEY);
|
||||
const hostname = JSON.parse(event.body).hostname;
|
||||
|
||||
let args: LoadFreeCertificateMethodArgs = {
|
||||
hostname,
|
||||
};
|
||||
|
||||
await bunnyCdn.loadFreeCertificate(args);
|
||||
|
||||
return formatJSONResponse({
|
||||
status: true,
|
||||
});
|
||||
} catch (e) {
|
||||
return formatJSONResponse({
|
||||
status: 500,
|
||||
message: e,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const submitAppInfo = async (
|
||||
event: APIGatewayEvent
|
||||
): Promise<APIGatewayProxyResult> => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
import { handlerPath } from '@libs/handler-resolver';
|
||||
|
||||
export const verifyApp = {
|
||||
handler: `${handlerPath(__dirname)}/handler.verifyApp`,
|
||||
events: [
|
||||
{
|
||||
http: {
|
||||
method: 'post',
|
||||
path: 'verifyApp',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const submitAppInfo = {
|
||||
handler: `${handlerPath(__dirname)}/handler.submitAppInfo`,
|
||||
events: [
|
||||
|
|
|
|||
Loading…
Reference in New Issue