Skip to content

Commit

Permalink
Merge pull request #54 from agnyz/feature/user-remaining-endpoints
Browse files Browse the repository at this point in the history
feat: user and profile endpoints
  • Loading branch information
yamcodes authored Oct 16, 2023
2 parents edd1175 + 8a382cc commit 414cb88
Show file tree
Hide file tree
Showing 26 changed files with 1,070 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"antfu.browse-lite",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg",
"bierner.markdown-preview-github-styles"
"bierner.markdown-preview-github-styles",
"Pandy.bun"
],
"settings": {
"editor.tabSize": 2,
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
### [Demo](https://demo.realworld.io/)    [RealWorld](https://github.com/gothinkster/realworld)


This codebase was created to demonstrate a fully fledged backend application built with **ElysiaJS** including CRUD operations, authentication, routing, pagination, and more.
This codebase was created to demonstrate a fully fledged backend application built with **Bun, ElysiaJS, and DrizzleORM** including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the **ElysiaJS** community styleguides & best practices.
We've gone to great lengths to adhere to the **Bun, ElysiaJS, and DrizzleORM** community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the [RealWorld](https://github.com/gothinkster/realworld) repo.

Expand Down
Binary file modified bun.lockb
Binary file not shown.
19 changes: 19 additions & 0 deletions db/migrations/0001_glorious_spectrum.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE IF NOT EXISTS "user_follows" (
"user_id" integer,
"follower_id" integer,
"created_at" date DEFAULT CURRENT_DATE,
"updated_at" date DEFAULT CURRENT_DATE,
CONSTRAINT user_follows_user_id_follower_id PRIMARY KEY("user_id","follower_id")
);

DO $$ BEGIN
ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

DO $$ BEGIN
ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_follower_id_users_id_fk" FOREIGN KEY ("follower_id") REFERENCES "users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
1 change: 1 addition & 0 deletions db/migrations/0002_aberrant_the_hunter.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "users" ALTER COLUMN "image" SET DEFAULT 'https://api.realworld.io/images/smiley-cyrus.jpg';
1 change: 1 addition & 0 deletions db/migrations/0003_tan_darwin.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "users" ALTER COLUMN "bio" SET DEFAULT '';
24 changes: 24 additions & 0 deletions db/migrations/0004_abandoned_maestro.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ALTER TABLE "user_follows"
ALTER COLUMN "user_id"
SET NOT NULL;
ALTER TABLE "user_follows"
ALTER COLUMN "follower_id"
SET NOT NULL;
ALTER TABLE "user_follows"
ALTER COLUMN "created_at"
SET NOT NULL;
ALTER TABLE "user_follows"
ALTER COLUMN "updated_at"
SET NOT NULL;
ALTER TABLE "users"
ALTER COLUMN "bio"
SET NOT NULL;
ALTER TABLE "users"
ALTER COLUMN "image"
SET NOT NULL;
ALTER TABLE "users"
ALTER COLUMN "created_at"
SET NOT NULL;
ALTER TABLE "users"
ALTER COLUMN "updated_at"
SET NOT NULL;
141 changes: 141 additions & 0 deletions db/migrations/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"version": "5",
"dialect": "pg",
"id": "37bce8eb-cbc0-456a-be7c-dd4a351999b2",
"prevId": "8ed456d0-e522-4f1a-a07e-a19b3cd900bc",
"tables": {
"user_follows": {
"name": "user_follows",
"schema": "",
"columns": {
"user_id": {
"name": "user_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"follower_id": {
"name": "follower_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
},
"updated_at": {
"name": "updated_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
}
},
"indexes": {},
"foreignKeys": {
"user_follows_user_id_users_id_fk": {
"name": "user_follows_user_id_users_id_fk",
"tableFrom": "user_follows",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"user_follows_follower_id_users_id_fk": {
"name": "user_follows_follower_id_users_id_fk",
"tableFrom": "user_follows",
"tableTo": "users",
"columnsFrom": ["follower_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"user_follows_user_id_follower_id": {
"name": "user_follows_user_id_follower_id",
"columns": ["user_id", "follower_id"]
}
},
"uniqueConstraints": {}
},
"users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"bio": {
"name": "bio",
"type": "text",
"primaryKey": false,
"notNull": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": true
},
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
},
"updated_at": {
"name": "updated_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_email_unique": {
"name": "users_email_unique",
"nullsNotDistinct": false,
"columns": ["email"]
}
}
}
},
"enums": {},
"schemas": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}
142 changes: 142 additions & 0 deletions db/migrations/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"version": "5",
"dialect": "pg",
"id": "d3648b42-2fea-42c2-a1d8-e55af14ec90a",
"prevId": "37bce8eb-cbc0-456a-be7c-dd4a351999b2",
"tables": {
"user_follows": {
"name": "user_follows",
"schema": "",
"columns": {
"user_id": {
"name": "user_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"follower_id": {
"name": "follower_id",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
},
"updated_at": {
"name": "updated_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
}
},
"indexes": {},
"foreignKeys": {
"user_follows_user_id_users_id_fk": {
"name": "user_follows_user_id_users_id_fk",
"tableFrom": "user_follows",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"user_follows_follower_id_users_id_fk": {
"name": "user_follows_follower_id_users_id_fk",
"tableFrom": "user_follows",
"tableTo": "users",
"columnsFrom": ["follower_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"user_follows_user_id_follower_id": {
"name": "user_follows_user_id_follower_id",
"columns": ["user_id", "follower_id"]
}
},
"uniqueConstraints": {}
},
"users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"bio": {
"name": "bio",
"type": "text",
"primaryKey": false,
"notNull": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"default": "'https://api.realworld.io/images/smiley-cyrus.jpg'"
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": true
},
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
},
"updated_at": {
"name": "updated_at",
"type": "date",
"primaryKey": false,
"notNull": false,
"default": "CURRENT_DATE"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_email_unique": {
"name": "users_email_unique",
"nullsNotDistinct": false,
"columns": ["email"]
}
}
}
},
"enums": {},
"schemas": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}
Loading

0 comments on commit 414cb88

Please sign in to comment.