Skip to content
This repository was archived by the owner on Apr 19, 2020. It is now read-only.

Commit dfe7f92

Browse files
committed
Initial commit
0 parents  commit dfe7f92

16 files changed

+7256
-0
lines changed

Diff for: .bilirc.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type Config = import('bili').Config
2+
3+
const config: Config = {
4+
input: ['src/index.ts'],
5+
output: {
6+
dir: 'lib',
7+
format: ['cjs', 'esm']
8+
}
9+
}
10+
11+
export default config

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Build directories
2+
lib

Diff for: .eslintrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
extends: [
3+
'standard-with-typescript',
4+
'plugin:prettier/recommended',
5+
'prettier/standard',
6+
'prettier/@typescript-eslint'
7+
],
8+
parserOptions: {
9+
project: './tsconfig.json',
10+
createDefaultProgram: true
11+
},
12+
rules: {
13+
'@typescript-eslint/camelcase': 'warn',
14+
'@typescript-eslint/consistent-type-definitions': 'off',
15+
'@typescript-eslint/no-empty-interface': 'warn',
16+
'@typescript-eslint/no-non-null-assertion': 'warn',
17+
'@typescript-eslint/promise-function-async': 'off',
18+
'@typescript-eslint/require-array-sort-compare': 'off',
19+
'@typescript-eslint/require-await': 'warn',
20+
'@typescript-eslint/strict-boolean-expressions': 'off'
21+
}
22+
}

Diff for: .gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Build directories
9+
lib
10+
11+
# Dependency directories
12+
node_modules
13+
14+
# Output of 'npm pack'
15+
*.tgz
16+
17+
# dotenv files
18+
.env
19+
20+
# Others
21+
coverage
22+
package-lock.json
23+
*.local

Diff for: .huskyrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const tasks = taskList => taskList.join(' && ')
2+
3+
module.exports = {
4+
hooks: {
5+
'pre-commit': tasks(['lint-staged', 'pretty-quick --staged'])
6+
}
7+
}

Diff for: .lintstagedrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
'src/**/*.ts': () => 'tsc -p tsconfig.json --noEmit',
3+
'src/**/*.ts': ['eslint']
4+
}

Diff for: .prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Build directories
2+
lib

Diff for: .prettierrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
endOfLine: 'lf',
3+
semi: false,
4+
singleQuote: true
5+
}

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Munif Tanjim
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[![Synor Database](https://img.shields.io/badge/synor-database-blue?style=for-the-badge)](https://github.com/Synor)
2+
[![Version](https://img.shields.io/npm/v/@synor/database-postgresql?style=for-the-badge)](https://npmjs.org/package/@synor/database-postgresql)
3+
[![Test](https://img.shields.io/travis/com/Synor/database-postgresql/master?label=Test&style=for-the-badge)](https://travis-ci.com/Synor/database-postgresql)
4+
[![Coverage](https://img.shields.io/codecov/c/gh/Synor/database-postgresql/master?style=for-the-badge)](https://codecov.io/gh/Synor/database-postgresql)
5+
[![License](https://img.shields.io/github/license/Synor/database-postgresql?style=for-the-badge)](https://github.com/Synor/database-postgresql/blob/master/LICENSE)
6+
7+
# Synor Database PostgreSQL
8+
9+
Synor Database Engine - PostgreSQL
10+
11+
## Installation
12+
13+
```sh
14+
# using yarn:
15+
yarn add @synor/database-postgresql
16+
17+
# using npm:
18+
npm install --save @synor/database-postgresql
19+
```
20+
21+
## URI
22+
23+
**Format**: `postgresql://[user[:password]@][hostname][:port][/dbname][?param1=value1&...]`
24+
25+
**Params**:
26+
27+
| Name | Description | Default Value |
28+
| ------------------------------ | ------------------------------- | ------------------------ |
29+
| `synor_migration_record_table` | Name for Migration Record Table | `synor_migration_record` |
30+
31+
**Examples**:
32+
33+
- `postgresql://postgres:[email protected]:5432/synor?synor_migration_record_table=migration_record`
34+
35+
## License
36+
37+
Licensed under the MIT License. Check the [LICENSE](./LICENSE) file for details.

Diff for: docker-compose.test.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3.1'
2+
3+
services:
4+
database:
5+
image: postgres:9.4-alpine
6+
restart: always
7+
environment:
8+
POSTGRES_PASSWORD: postgres
9+
POSTGRES_DB: synor
10+
ports:
11+
- 5432:5432

Diff for: jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: './jest.env.js'
4+
}

Diff for: jest.env.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const NodeEnvironment = require('jest-environment-node')
2+
const { execSync } = require('child_process')
3+
4+
const uri = 'postgresql://postgres:[email protected]:5432/synor'
5+
6+
const sleep = async ms => new Promise(resolve => setTimeout(resolve, ms))
7+
8+
const pingPostgreSQL = () => {
9+
execSync(`pg_isready -d ${uri} -q`, { stdio: 'ignore' })
10+
}
11+
12+
async function waitForPostgreSQL() {
13+
try {
14+
pingPostgreSQL()
15+
} catch (_) {
16+
console.log(_)
17+
await sleep(1000)
18+
return waitForPostgreSQL()
19+
}
20+
}
21+
22+
class SynorDatabasePostgreSQLTestEnvironment extends NodeEnvironment {
23+
constructor(config, context) {
24+
super(config, context)
25+
this.docblockPragmas = context.docblockPragmas
26+
}
27+
28+
async setup() {
29+
await super.setup()
30+
await waitForPostgreSQL()
31+
}
32+
33+
async teardown() {
34+
await super.teardown()
35+
}
36+
37+
runScript(script) {
38+
return super.runScript(script)
39+
}
40+
}
41+
42+
module.exports = SynorDatabasePostgreSQLTestEnvironment

Diff for: package.json

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "@synor/database-postgresql",
3+
"version": "0.0.0",
4+
"description": "Synor Database Engine - PostgreSQL",
5+
"keywords": [
6+
"synor",
7+
"synor-database",
8+
"postgresql",
9+
"postgres",
10+
"pg"
11+
],
12+
"homepage": "https://github.com/Synor/database-postgresql#readme",
13+
"bugs": "https://github.com/Synor/database-postgresql/issues",
14+
"license": "MIT",
15+
"author": "Munif Tanjim (https://muniftanjim.dev)",
16+
"files": [
17+
"lib"
18+
],
19+
"main": "lib/index.js",
20+
"module": "lib/index.esm.js",
21+
"types": "lib/index.d.ts",
22+
"repository": "https://github.com/Synor/database-postgresql",
23+
"scripts": {
24+
"prebuild": "npm run clean",
25+
"build": "bili",
26+
"clean": "rimraf lib/*",
27+
"prepack": "npm run build",
28+
"test": "jest"
29+
},
30+
"dependencies": {
31+
"connection-string": "^3.1.0",
32+
"debug": "^4.1.1",
33+
"pg": "^7.15.1"
34+
},
35+
"devDependencies": {
36+
"@synor/core": "^0.4.1",
37+
"@types/debug": "^4.1.5",
38+
"@types/jest": "^24.0.24",
39+
"@types/pg": "^7.14.0",
40+
"@typescript-eslint/eslint-plugin": "^2.13.0",
41+
"@typescript-eslint/parser": "^2.13.0",
42+
"bili": "^4.8.1",
43+
"eslint": "^6.8.0",
44+
"eslint-config-prettier": "^6.4.0",
45+
"eslint-config-standard-with-typescript": "^11.0.1",
46+
"eslint-plugin-import": "^2.18.2",
47+
"eslint-plugin-node": "^10.0.0",
48+
"eslint-plugin-prettier": "^3.1.2",
49+
"eslint-plugin-promise": "^4.2.1",
50+
"eslint-plugin-standard": "^4.0.1",
51+
"husky": "^3.0.9",
52+
"jest": "^24.9.0",
53+
"lint-staged": "^9.4.2",
54+
"prettier": "^1.18.2",
55+
"pretty-quick": "^2.0.0",
56+
"rimraf": "^3.0.0",
57+
"rollup-plugin-typescript2": "^0.25.2",
58+
"ts-jest": "^24.1.0",
59+
"ts-node": "^8.5.4",
60+
"typescript": "^3.7.4"
61+
},
62+
"peerDependencies": {
63+
"@synor/core": "^0.4.1"
64+
},
65+
"publishConfig": {
66+
"access": "public"
67+
}
68+
}

Diff for: tsconfig.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"compilerOptions": {
3+
/* Basic Options */
4+
// "incremental": true, /* Enable incremental compilation */
5+
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
6+
"module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
7+
// "lib": [], /* Specify library files to be included in the compilation. */
8+
// "allowJs": true, /* Allow javascript files to be compiled. */
9+
// "checkJs": true, /* Report errors in .js files. */
10+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
11+
"declaration": true /* Generates corresponding '.d.ts' file. */,
12+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
13+
// "sourceMap": true /* Generates corresponding '.map' file. */,
14+
// "outFile": "./", /* Concatenate and emit output to single file. */
15+
"outDir": "./lib" /* Redirect output structure to the directory. */,
16+
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
17+
// "composite": true, /* Enable project compilation */
18+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
19+
// "removeComments": true, /* Do not emit comments to output. */
20+
"noEmit": true /* Do not emit outputs. */,
21+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
22+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
23+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
24+
25+
/* Strict Type-Checking Options */
26+
"strict": true /* Enable all strict type-checking options. */,
27+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
28+
// "strictNullChecks": true, /* Enable strict null checks. */
29+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
30+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
31+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
32+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
33+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
34+
35+
/* Additional Checks */
36+
// "noUnusedLocals": true, /* Report errors on unused locals. */
37+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
38+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
39+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
40+
41+
/* Module Resolution Options */
42+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
43+
// "baseUrl": "./src", /* Base directory to resolve non-absolute module names. */
44+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
45+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
46+
// "typeRoots": [], /* List of folders to include type definitions from. */
47+
// "types": [], /* Type declaration files to be included in compilation. */
48+
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
49+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
50+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
51+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
52+
53+
/* Source Map Options */
54+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
55+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
56+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
57+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
58+
59+
/* Experimental Options */
60+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
61+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
62+
},
63+
"include": ["src"],
64+
"exclude": ["src/**/*.test.ts", "src/**/*.snap"]
65+
}

0 commit comments

Comments
 (0)