feat: serverless new mint handler placeholder (#221)
* feat: add handler. * fix: make the handler compilable. * feat: parse json
This commit is contained in:
parent
737715e1e3
commit
957219b8af
|
|
@ -5,6 +5,8 @@ jspm_packages
|
|||
# Serverless directories
|
||||
.serverless
|
||||
|
||||
yarn-error.log
|
||||
|
||||
# esbuild directories
|
||||
.esbuild
|
||||
|
||||
|
|
|
|||
|
|
@ -36,4 +36,12 @@ functions:
|
|||
- http:
|
||||
path: build
|
||||
method: post
|
||||
cors: true
|
||||
|
||||
submitMintInfo:
|
||||
handler: dist/functions/mints/handler.submitMintInfo
|
||||
events:
|
||||
- http:
|
||||
path: mint
|
||||
method: post
|
||||
cors: true
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
import {
|
||||
APIGatewayProxyResult,
|
||||
APIGatewayEvent,
|
||||
///APIGatewayEventRequestContext,
|
||||
} from 'aws-lambda';
|
||||
import { formatJSONResponse } from '@libs/api-gateway';
|
||||
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
export const submitMintInfo = async (
|
||||
event: APIGatewayEvent,
|
||||
///context: APIGatewayEventRequestContext
|
||||
): Promise<APIGatewayProxyResult> => {
|
||||
try {
|
||||
const id = v4();
|
||||
|
||||
/**if (!verifyAlchemySig(event.headers.xalchemywork)) {
|
||||
throw new Error('Invalid sig');
|
||||
}**/
|
||||
|
||||
if (event.body == undefined) {
|
||||
throw new Error('Undefined data');
|
||||
}
|
||||
|
||||
const mintInfo = {
|
||||
buildId: id,
|
||||
createdAt: new Date().toISOString(),
|
||||
body: JSON.parse(event.body),
|
||||
};
|
||||
|
||||
// check if we have it in mongo
|
||||
// if so, trigger verification call
|
||||
// if not, add to mongo
|
||||
|
||||
return formatJSONResponse({
|
||||
mintInfo,
|
||||
});
|
||||
} catch (e) {
|
||||
return formatJSONResponse({
|
||||
status: 500,
|
||||
message: e,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { handlerPath } from '@libs/handler-resolver';
|
||||
|
||||
export const newMint = {
|
||||
handler: `${handlerPath(__dirname)}/handler.newMint`,
|
||||
events: [
|
||||
{
|
||||
http: {
|
||||
method: 'post',
|
||||
path: 'mint',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
Loading…
Reference in New Issue