commit ac2a5dc744317c4e8495493ad6129363e78bb458 Author: Aritra Banik Date: Sat Jun 29 19:18:46 2024 +0530 20 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..01072ca --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.v] +indent_style = tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f4011a7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +* text=auto eol=lf +*.bat eol=crlf + +**/*.v linguist-language=V +**/*.vv linguist-language=V +**/*.vsh linguist-language=V +**/v.mod linguist-language=V diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..138fdc5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Binaries for programs and plugins +main +v5 +*.exe +*.exe~ +*.so +*.dylib +*.dll + +# Ignore binary output folders +bin/ + +# Ignore common editor/system specific metadata +.DS_Store +.idea/ +.vscode/ +*.iml + +# ENV +.env + +# vweb and database +*.db +*.js diff --git a/databases/config_databases_sqlite.v b/databases/config_databases_sqlite.v new file mode 100644 index 0000000..df58d89 --- /dev/null +++ b/databases/config_databases_sqlite.v @@ -0,0 +1,8 @@ +module databases + +import db.sqlite // can change to 'db.mysql', 'db.pg' + +pub fn create_db_connection() !sqlite.DB { + mut db := sqlite.connect('app.db')! + return db +} diff --git a/src/controller.v b/src/controller.v new file mode 100644 index 0000000..caea359 --- /dev/null +++ b/src/controller.v @@ -0,0 +1,8 @@ +module main + +import vweb + +@[post] +pub fn (mut app App) signup() vweb.Result{ + return $vweb.html() +} \ No newline at end of file diff --git a/src/entitities.v b/src/entitities.v new file mode 100644 index 0000000..a2987f8 --- /dev/null +++ b/src/entitities.v @@ -0,0 +1,12 @@ +module main + +@[table: 'auth'] +pub struct Auth { +mut: + id int @[primary; sql: serial] + username string @[sql_type: 'TEXT'] + email string @[sql_type: 'TEXT'; unique] + access_level int @[sql_type: 'INTEGER'] + password string @[sql_type: 'TEXT'] + // products []Product @[fkey: 'user_id'] +} diff --git a/src/main.v b/src/main.v new file mode 100644 index 0000000..b1eada4 --- /dev/null +++ b/src/main.v @@ -0,0 +1,45 @@ +module main + +import vweb +import os +import databases + +const ( + port = 8082 +) + +struct App { + vweb.Context +} + +pub fn (app App) before_request() { + println('[web] before_request: ${app.req.method} ${app.req.url}') +} + +fn main() { + mut db := databases.create_db_connection() or { panic(err) } + + sql db { + // create table Faculty ( + // id serial primary key, + // name text not null, + // email text not null unique, + // password text not null + // ) + create table Auth + } or { panic('error on create table: ${err}') } + + db.close() or { panic(err) } + + mut app := &App{} + app.serve_static('/favicon.ico', 'src/assets/favicon.ico') + // makes all static files available. + app.mount_static_folder_at(os.resource_abs_path('.'), '/') + + vweb.run(app, port) +} + +pub fn (mut app App) login() vweb.Result { + + return $vweb.html() +} diff --git a/src/services.v b/src/services.v new file mode 100644 index 0000000..e69de29 diff --git a/src/templates/login.html b/src/templates/login.html new file mode 100644 index 0000000..e4272ce --- /dev/null +++ b/src/templates/login.html @@ -0,0 +1,24 @@ + + + + Log In + + @css 'https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css' + + +
+

Welcome Back!

+
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/templates/signup.html b/src/templates/signup.html new file mode 100644 index 0000000..5c1fc6d --- /dev/null +++ b/src/templates/signup.html @@ -0,0 +1,28 @@ + + + + Sign Up + + @css 'https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css' + + +
+

Create an Account

+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/src/view.v b/src/view.v new file mode 100644 index 0000000..7982995 --- /dev/null +++ b/src/view.v @@ -0,0 +1,7 @@ +module main + +import vweb + +pub fn (mut app App) signup() vweb.Result{ + return $vweb.html() +} \ No newline at end of file diff --git a/src/view_api.v b/src/view_api.v new file mode 100644 index 0000000..e69de29 diff --git a/v.mod b/v.mod new file mode 100644 index 0000000..80b8d18 --- /dev/null +++ b/v.mod @@ -0,0 +1,7 @@ +Module { + name: 'v5' + description: 'An Authentication API' + version: '0.0.0' + license: 'MIT' + dependencies: [] +}