This file contains hidden or 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 { BasicStrategy as Strategy } from 'passport-http'; | |
import { Injectable, InternalServerErrorException, UnauthorizedException } from '@nestjs/common'; | |
import { PassportStrategy } from '@nestjs/passport'; | |
import { ConfigService } from '@nestjs/config'; | |
import { timingSafeEqual } from 'crypto'; | |
@Injectable() | |
export class AdminBasicStrategy extends PassportStrategy(Strategy) { | |
constructor(private readonly configService: ConfigService) { |
This file contains hidden or 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
"test": "mocha \"test/**/*.spec.js\"" | |
# TypeScript development | |
"test": "mocha -r ts-node/register \"src/test/**/*.spec.ts\"" |
This file contains hidden or 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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | |
"outDir": "./dist", /* Redirect output structure to the directory. */ | |
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | |
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ | |
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | |
"skipLibC |
This file contains hidden or 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
{ | |
"main": "index.js", | |
"scripts": { | |
"clean": "rimraf dist", | |
"start": "NODE_ENV=production node -r ts-node/register/transpile-only -r tsconfig-paths/register ./dist/index.js", | |
"build": "npm run clean && tsc", | |
"dev": "NODE_ENV=development ts-node-dev -r tsconfig-paths/register ./src/index.ts", | |
"test": "mocha -r ts-node/register \"src/test/**/*.spec.ts\"", | |
"pm2:dev": "npm run build && pm2 start pm2_dev.config.js", | |
"pm2:prod": "npm run build && pm2 start pm2_prod.config.js", |
This file contains hidden or 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
pragma solidity >=0.5.12; | |
// FIXME: This contract was altered compared to the production version. | |
// It doesn't use LibNote anymore. | |
// New deployments of this contract will need to include custom events (TO DO). | |
contract Dai { | |
// --- Auth --- | |
mapping (address => uint) public wards; | |
function rely(address guy) external auth { wards[guy] = 1; } |
This file contains hidden or 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
npm init -y | |
echo "node_modules\n.env" > .gitignore | |
echo "# Node.js Boilerplate Sample" > README.md | |
touch .env | |
mkdir -p src/test && touch src/index.js | |
mkdir -p src/lib | |
mkdir -p .github/workflows && touch .github/workflows/actions.yaml | |
mkdir .vscode && touch .vscode/settings.json | |
touch .prettierrc | |
git init |
This file contains hidden or 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
const ethUtil = require('ethereumjs-util'); | |
const abi = require('ethereumjs-abi'); | |
const chai = require('chai'); | |
const typedData = { | |
types: { | |
EIP712Domain: [ | |
{ name: 'name', type: 'string' }, | |
{ name: 'version', type: 'string' }, | |
{ name: 'chainId', type: 'uint256' }, |
This file contains hidden or 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 React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
// React Navigation | |
import { createAppContainer, createSwitchNavigator } from 'react-navigation'; | |
import { createStackNavigator } from 'react-navigation-stack'; | |
import { createBottomTabNavigator } from 'react-navigation-tabs'; | |
// Screen | |
import AccountScreen from './src/screens/AccountScreen'; | |
import DashboardScreen from './src/screens/DashboardScreen'; | |
import IndexScreen from './src/screens/IndexScreen'; |
This file contains hidden or 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 React, { createContext, useState, useReducer } from 'react'; | |
import createDataContext from './createDataContext'; | |
const initialState = []; | |
const blogReducer = (state, action) => { | |
switch (action.type) { | |
case 'ADD_BLOGPOST': | |
return [...state, { title: `Blog Post #${state.length + 1}` }]; |
This file contains hidden or 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 React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
import { createAppContainer, createSwitchNavigator } from 'react-navigation'; | |
import { createStackNavigator } from 'react-navigation-stack'; | |
import { createBottomTabNavigator } from 'react-navigation-tabs'; | |
// Screen | |
import IndexScreen from './src/screens/IndexScreen'; | |
const navigator = createStackNavigator( |