This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from 'express-json-validator-middleware' package https://github.com/simonplend/express-json-validator-middleware | |
// Modified to be able to use @apideck/better-ajv-errors package | |
// Relevant Github Issue: https://github.com/simonplend/express-json-validator-middleware/issues/123 | |
import { | |
betterAjvErrors, | |
ValidationError as BetterAjvErrorObject, | |
} from "@apideck/better-ajv-errors"; | |
import { Request } from "express"; | |
import { RequestHandler } from "express-serve-static-core"; | |
import { JSONSchema6 } from "json-schema"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("can use a transaction for the current test and roll it back after", async function () { | |
const transactionForThisTest = await MyObjectionJsModel.startTransaction(); | |
spyOn(MyObjectionJsModel, "query") | |
.withArgs() | |
.and.callFake(() => MyObjectionJsModel.query(transactionForThisTest) as any) | |
.withArgs(transactionForThisTest) | |
.and.callThrough(); | |
const result = await someMethodThatChangesTheDatabaseState(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model } from "objection"; | |
import _ from "lodash"; | |
export class ExtendedObjectionModel extends Model { | |
// Use this instead of Objection's Model when making your models to fix the "is not a string" error you get when saving a JS date object to a psql datetime (timestamp) column. | |
// This is a WIP you may need to make some modifications. | |
// The main idea is to check those fields which we said should be "date-time" formatted strings in their model's jsonSchema before validation runs. If the field is a JS date, convert it to a string now before running real validation. | |
$beforeValidate(jsonSchema, json, opt) { | |
_.each(jsonSchema.properties, (schema, propertyName) => { | |
if ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
#env: | |
#variables: | |
# key: "value" | |
# key: "value" | |
#parameter-store: | |
# key: "value" | |
# key: "value" | |
#secrets-manager: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
phases: | |
install: | |
runtime-versions: | |
python: 3.8 | |
build: | |
commands: | |
- pip install pipenv --user | |
- pipenv run python -m pip install pip==19.2.3 # helped resolve a bug I encountered in deploying by downgrading - can try leaving to most up to date again in the future | |
- pipenv install awscli aws-sam-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
namespace CSharpSqlIdentifierParser | |
{ | |
public class CSharpSqlIdentifierParserClass | |
{ | |
// Parses funky sql identifiers as strings back as their individual components which hopefully makes them easier to read | |
// Examples: |