@odvi/create-dtt-framework 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 DTT Framework
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.
@@ -0,0 +1,18 @@
1
+ CREATE TABLE "users" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "email" varchar(255) NOT NULL,
4
+ "first_name" varchar(255),
5
+ "last_name" varchar(255),
6
+ "image_url" text,
7
+ "clerk_org_id" text,
8
+ "created_at" timestamp DEFAULT now() NOT NULL,
9
+ "updated_at" timestamp DEFAULT now() NOT NULL,
10
+ CONSTRAINT "users_email_unique" UNIQUE("email")
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE "health_check_tests" (
14
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
15
+ "test_key" text NOT NULL,
16
+ "test_value" text,
17
+ "created_at" timestamp DEFAULT now() NOT NULL
18
+ );
@@ -0,0 +1,129 @@
1
+ {
2
+ "id": "8ef2966f-b7b3-4fd4-adfc-84bfe2fdbf38",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.users": {
8
+ "name": "users",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "email": {
18
+ "name": "email",
19
+ "type": "varchar(255)",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "first_name": {
24
+ "name": "first_name",
25
+ "type": "varchar(255)",
26
+ "primaryKey": false,
27
+ "notNull": false
28
+ },
29
+ "last_name": {
30
+ "name": "last_name",
31
+ "type": "varchar(255)",
32
+ "primaryKey": false,
33
+ "notNull": false
34
+ },
35
+ "image_url": {
36
+ "name": "image_url",
37
+ "type": "text",
38
+ "primaryKey": false,
39
+ "notNull": false
40
+ },
41
+ "clerk_org_id": {
42
+ "name": "clerk_org_id",
43
+ "type": "text",
44
+ "primaryKey": false,
45
+ "notNull": false
46
+ },
47
+ "created_at": {
48
+ "name": "created_at",
49
+ "type": "timestamp",
50
+ "primaryKey": false,
51
+ "notNull": true,
52
+ "default": "now()"
53
+ },
54
+ "updated_at": {
55
+ "name": "updated_at",
56
+ "type": "timestamp",
57
+ "primaryKey": false,
58
+ "notNull": true,
59
+ "default": "now()"
60
+ }
61
+ },
62
+ "indexes": {},
63
+ "foreignKeys": {},
64
+ "compositePrimaryKeys": {},
65
+ "uniqueConstraints": {
66
+ "users_email_unique": {
67
+ "name": "users_email_unique",
68
+ "nullsNotDistinct": false,
69
+ "columns": [
70
+ "email"
71
+ ]
72
+ }
73
+ },
74
+ "policies": {},
75
+ "checkConstraints": {},
76
+ "isRLSEnabled": false
77
+ },
78
+ "public.health_check_tests": {
79
+ "name": "health_check_tests",
80
+ "schema": "",
81
+ "columns": {
82
+ "id": {
83
+ "name": "id",
84
+ "type": "uuid",
85
+ "primaryKey": true,
86
+ "notNull": true,
87
+ "default": "gen_random_uuid()"
88
+ },
89
+ "test_key": {
90
+ "name": "test_key",
91
+ "type": "text",
92
+ "primaryKey": false,
93
+ "notNull": true
94
+ },
95
+ "test_value": {
96
+ "name": "test_value",
97
+ "type": "text",
98
+ "primaryKey": false,
99
+ "notNull": false
100
+ },
101
+ "created_at": {
102
+ "name": "created_at",
103
+ "type": "timestamp",
104
+ "primaryKey": false,
105
+ "notNull": true,
106
+ "default": "now()"
107
+ }
108
+ },
109
+ "indexes": {},
110
+ "foreignKeys": {},
111
+ "compositePrimaryKeys": {},
112
+ "uniqueConstraints": {},
113
+ "policies": {},
114
+ "checkConstraints": {},
115
+ "isRLSEnabled": false
116
+ }
117
+ },
118
+ "enums": {},
119
+ "schemas": {},
120
+ "sequences": {},
121
+ "roles": {},
122
+ "policies": {},
123
+ "views": {},
124
+ "_meta": {
125
+ "columns": {},
126
+ "schemas": {},
127
+ "tables": {}
128
+ }
129
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1767269294126,
9
+ "tag": "0000_awesome_argent",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,61 @@
1
+ import { FlatCompat } from "@eslint/eslintrc";
2
+ import tseslint from "typescript-eslint";
3
+ // @ts-ignore -- no types for this plugin
4
+ import drizzle from "eslint-plugin-drizzle";
5
+
6
+ const compat = new FlatCompat({
7
+ baseDirectory: import.meta.dirname,
8
+ });
9
+
10
+ export default tseslint.config(
11
+ {
12
+ ignores: [".next"],
13
+ },
14
+ ...compat.extends("next/core-web-vitals"),
15
+ {
16
+ files: ["**/*.ts", "**/*.tsx"],
17
+ plugins: {
18
+ drizzle,
19
+ },
20
+ extends: [
21
+ ...tseslint.configs.recommended,
22
+ ...tseslint.configs.recommendedTypeChecked,
23
+ ...tseslint.configs.stylisticTypeChecked,
24
+ ],
25
+ rules: {
26
+ "@typescript-eslint/array-type": "off",
27
+ "@typescript-eslint/consistent-type-definitions": "off",
28
+ "@typescript-eslint/consistent-type-imports": [
29
+ "warn",
30
+ { prefer: "type-imports", fixStyle: "inline-type-imports" },
31
+ ],
32
+ "@typescript-eslint/no-unused-vars": [
33
+ "warn",
34
+ { argsIgnorePattern: "^_" },
35
+ ],
36
+ "@typescript-eslint/require-await": "off",
37
+ "@typescript-eslint/no-misused-promises": [
38
+ "error",
39
+ { checksVoidReturn: { attributes: false } },
40
+ ],
41
+ "drizzle/enforce-delete-with-where": [
42
+ "error",
43
+ { drizzleObjectName: ["db", "ctx.db"] },
44
+ ],
45
+ "drizzle/enforce-update-with-where": [
46
+ "error",
47
+ { drizzleObjectName: ["db", "ctx.db"] },
48
+ ],
49
+ },
50
+ },
51
+ {
52
+ linterOptions: {
53
+ reportUnusedDisableDirectives: true,
54
+ },
55
+ languageOptions: {
56
+ parserOptions: {
57
+ projectService: true,
58
+ },
59
+ },
60
+ },
61
+ );
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ # Use this script to start a docker container for a local development database
3
+
4
+ # TO RUN ON WINDOWS:
5
+ # 1. Install WSL (Windows Subsystem for Linux) - https://learn.microsoft.com/en-us/windows/wsl/install
6
+ # 2. Install Docker Desktop or Podman Deskop
7
+ # - Docker Desktop for Windows - https://docs.docker.com/docker-for-windows/install/
8
+ # - Podman Desktop - https://podman.io/getting-started/installation
9
+ # 3. Open WSL - `wsl`
10
+ # 4. Run this script - `./start-database.sh`
11
+
12
+ # On Linux and macOS you can run this script directly - `./start-database.sh`
13
+
14
+ # import env variables from .env
15
+ set -a
16
+ source .env
17
+
18
+ DB_PASSWORD=$(echo "$DATABASE_URL" | awk -F':' '{print $3}' | awk -F'@' '{print $1}')
19
+ DB_PORT=$(echo "$DATABASE_URL" | awk -F':' '{print $4}' | awk -F'\/' '{print $1}')
20
+ DB_NAME=$(echo "$DATABASE_URL" | awk -F'/' '{print $4}')
21
+ DB_CONTAINER_NAME="$DB_NAME-postgres"
22
+
23
+ if ! [ -x "$(command -v docker)" ] && ! [ -x "$(command -v podman)" ]; then
24
+ echo -e "Docker or Podman is not installed. Please install docker or podman and try again.\nDocker install guide: https://docs.docker.com/engine/install/\nPodman install guide: https://podman.io/getting-started/installation"
25
+ exit 1
26
+ fi
27
+
28
+ # determine which docker command to use
29
+ if [ -x "$(command -v docker)" ]; then
30
+ DOCKER_CMD="docker"
31
+ elif [ -x "$(command -v podman)" ]; then
32
+ DOCKER_CMD="podman"
33
+ fi
34
+
35
+ if ! $DOCKER_CMD info > /dev/null 2>&1; then
36
+ echo "$DOCKER_CMD daemon is not running. Please start $DOCKER_CMD and try again."
37
+ exit 1
38
+ fi
39
+
40
+ if command -v nc >/dev/null 2>&1; then
41
+ if nc -z localhost "$DB_PORT" 2>/dev/null; then
42
+ echo "Port $DB_PORT is already in use."
43
+ exit 1
44
+ fi
45
+ else
46
+ echo "Warning: Unable to check if port $DB_PORT is already in use (netcat not installed)"
47
+ read -p "Do you want to continue anyway? [y/N]: " -r REPLY
48
+ if ! [[ $REPLY =~ ^[Yy]$ ]]; then
49
+ echo "Aborting."
50
+ exit 1
51
+ fi
52
+ fi
53
+
54
+ if [ "$($DOCKER_CMD ps -q -f name=$DB_CONTAINER_NAME)" ]; then
55
+ echo "Database container '$DB_CONTAINER_NAME' already running"
56
+ exit 0
57
+ fi
58
+
59
+ if [ "$($DOCKER_CMD ps -q -a -f name=$DB_CONTAINER_NAME)" ]; then
60
+ $DOCKER_CMD start "$DB_CONTAINER_NAME"
61
+ echo "Existing database container '$DB_CONTAINER_NAME' started"
62
+ exit 0
63
+ fi
64
+
65
+ if [ "$DB_PASSWORD" = "password" ]; then
66
+ echo "You are using the default database password"
67
+ read -p "Should we generate a random password for you? [y/N]: " -r REPLY
68
+ if ! [[ $REPLY =~ ^[Yy]$ ]]; then
69
+ echo "Please change the default password in the .env file and try again"
70
+ exit 1
71
+ fi
72
+ # Generate a random URL-safe password
73
+ DB_PASSWORD=$(openssl rand -base64 12 | tr '+/' '-_')
74
+ if [[ "$(uname)" == "Darwin" ]]; then
75
+ # macOS requires an empty string to be passed with the `i` flag
76
+ sed -i '' "s#:password@#:$DB_PASSWORD@#" .env
77
+ else
78
+ sed -i "s#:password@#:$DB_PASSWORD@#" .env
79
+ fi
80
+ fi
81
+
82
+ $DOCKER_CMD run -d \
83
+ --name $DB_CONTAINER_NAME \
84
+ -e POSTGRES_USER="postgres" \
85
+ -e POSTGRES_PASSWORD="$DB_PASSWORD" \
86
+ -e POSTGRES_DB="$DB_NAME" \
87
+ -p "$DB_PORT":5432 \
88
+ docker.io/postgres && echo "Database container '$DB_CONTAINER_NAME' was successfully created"