From 52afd35ba54b5f75e0e038d2c4950c508b777137 Mon Sep 17 00:00:00 2001 From: Aritra Banik Date: Tue, 4 Mar 2025 01:42:11 +0530 Subject: [PATCH] 001 --- .editorconfig | 8 ++++++++ .gitattributes | 8 ++++++++ .gitignore | 24 ++++++++++++++++++++++++ src/main.v | 23 +++++++++++++++++++++++ src/todo_entities.v | 10 ++++++++++ src/user_entities.v | 9 +++++++++ v.mod | 7 +++++++ 7 files changed, 89 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 src/main.v create mode 100644 src/todo_entities.v create mode 100644 src/user_entities.v create mode 100644 v.mod 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..9a98968 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +* text=auto eol=lf +*.bat eol=crlf + +*.v linguist-language=V +*.vv linguist-language=V +*.vsh linguist-language=V +v.mod linguist-language=V +.vdocignore linguist-language=ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e8431a --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Binaries for programs and plugins +main +todo2 +*.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/src/main.v b/src/main.v new file mode 100644 index 0000000..d35cd53 --- /dev/null +++ b/src/main.v @@ -0,0 +1,23 @@ +module main + +import veb + +pub struct Context { + veb.Context +} + +pub struct App { + veb.StaticHandler +} + +fn main() { + mut app := &App{} + + app.handle_static('static', false)! + + veb.run[App, Context](mut app, 8080) +} + +pub fn (app &App) index(mut ctx Context) veb.Result { + return ctx.text('Namaste India!!') +} diff --git a/src/todo_entities.v b/src/todo_entities.v new file mode 100644 index 0000000..68e7db4 --- /dev/null +++ b/src/todo_entities.v @@ -0,0 +1,10 @@ +module main + +@[table: 'todo'] +pub struct Todo { +mut: + id int @[primary; sql: serial] + user_id int + todo string @[nonull; sql_type: 'TEXT'] + status string @[nonull; sql_type: 'TEXT'] +} diff --git a/src/user_entities.v b/src/user_entities.v new file mode 100644 index 0000000..a7ffe3d --- /dev/null +++ b/src/user_entities.v @@ -0,0 +1,9 @@ +module main + +@[table: 'users'] +pub struct User { +mut: + id int @[primary; sql: serial] + username string @[nonull; sql_type: 'TEXT'; unique] + todos []Todo @[fkey: 'user_id'] +} diff --git a/v.mod b/v.mod new file mode 100644 index 0000000..89288eb --- /dev/null +++ b/v.mod @@ -0,0 +1,7 @@ +Module { + name: 'todo2' + description: '' + version: '0.0.0' + license: 'MIT' + dependencies: [] +}