Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const validator = validateRequestBody({
noteId: [],
userId: [],
content: [required], // TODO: validate slate schema
title: [required, isString],
tags: [required, isArray(v => typeof v === "string")],
dateUpdated: [],
overwrite: []
});
export const handler = middy(update)
.use(jsonBodyParser())
.use(validator)
.use(encodeResponse())
.use(jsonErrorHandler())
.use(cors());
ACL: "public-read"
}).promise();
const src = `https://s3-${process.env.REGION}.amazonaws.com/${process.env.EXPORT_BUCKET}/${S3UploadPath}`;
const response: ExportResponseDTO = { src };
return callback(null, success(response));
};
export const handler = middy(markdown)
.use(jsonBodyParser())
.use(validator)
.use(encodeResponse())
.use(jsonErrorHandler())
.use(cors());
const handlerBuilder = (aws) => {
return middy(new ProjectsDeleteHandler(aws))
.use(checkApiKey())
.use(httpErrorHandler())
.use(bodyStringifier())
.use(cors());
};
const handler = handlerBuilder(aws);
const handlerBuilder = (aws) => {
return middy(new OccurrencesListHandler(aws))
.use(httpHeaderNormalizer())
.use(checkApiKey())
.use(httpErrorHandler())
.use(bodyStringifier())
.use(cors());
};
const handler = handlerBuilder(aws);
import { encodeResponse } from "@internote/lib/middlewares";
import { success } from "@internote/lib/responses";
import { getUserIdentityId } from "@internote/lib/user";
import { GetHandler } from "@internote/lib/types";
import { listNotesByUserId } from "./db/queries";
const list: GetHandler = async (event, _ctx, callback) => {
const userId = getUserIdentityId(event);
const notes = await listNotesByUserId(userId);
return callback(null, success(notes));
};
export const handler = middy(list)
.use(encodeResponse())
.use(httpErrorHandler())
.use(cors());
event,
_ctx,
callback
) => {
const userId = getUserIdentityId(event);
const noteId = uuid();
const note = await createSnippet(noteId, userId, event.body);
return callback(null, success(note));
};
export const handler = middy(create)
.use(jsonBodyParser())
.use(validator)
.use(encodeResponse())
.use(jsonErrorHandler())
.use(cors());
const handlerBuilder = (aws) => {
return middy(new OccurrencesGetHandler(aws))
.use(httpHeaderNormalizer())
.use(checkApiKey())
.use(httpErrorHandler())
.use(bodyStringifier())
.use(cors());
};
const handler = handlerBuilder(aws);
const handlerBuilder = (aws) => {
return middy(new ErrorsPatchHandler(aws))
.use(checkApiKey())
.use(httpErrorHandler())
.use(bodyStringifier())
.use(cors());
};
const handler = handlerBuilder(aws);
const del33t: DeleteHandler<{ noteId: string }> = async (
event,
_ctx,
callback
) => {
const { noteId } = event.pathParameters;
const userId = getUserIdentityId(event);
await deleteNoteById(noteId, userId);
return callback(null, success({}));
};
export const handler = middy(del33t)
.use(encodeResponse())
.use(httpErrorHandler())
.use(cors());
const list: GetHandler = async (event, _ctx, callback) => {
const userId = getUserIdentityId(event);
const notes = await listNotesByUserId(userId);
const allTags = notes.reduce(
(ts, note) => [...ts, ...note.tags],
[] as string[]
);
const dedupedTags = [...new Set(allTags)];
return callback(null, success(dedupedTags));
};
export const handler = middy(list)
.use(encodeResponse())
.use(httpErrorHandler())
.use(cors());