commit 8a5a051e7a407c41c62a4d6282b5d8e917c3491c Author: Maulana Sodiqin Date: Mon Feb 3 21:53:42 2025 +0700 chore: initial commit diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..0a59870 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[env] +RUST_LOG="imphnen-cms-api=debug" +RUST_ENV="development" + +[profile.release] +lto = "fat" +codegen-units = 1 +panic = "abort" +opt-level = "z" diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a699ddd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +target +.dockerignore +Dockerfile +.git +.gitignore diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e69de29 diff --git a/.envrc.example b/.envrc.example new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6febb3e --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Build +/target +/resutl + +# Nix +/.direnv + +# Environment +.envrc +.env +.env.local +.env.development +.env.staging +.env.production diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a8ee18d --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,726 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "axum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "multer", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + +[[package]] +name = "bytes" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "imphnen-cms-be" +version = "0.1.0" +dependencies = [ + "axum", + "serde", + "serde_json", + "tokio", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi", + "windows-sys", +] + +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "memchr", + "mime", + "spin", + "version_check", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + +[[package]] +name = "ryu" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "tokio" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f313a43 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "imphnen-cms-be" +version = "0.1.0" +edition = "2021" + +[dependencies] +axum = { version = "0.8.1", features = ["multipart"] } +serde = { version = "1.0.217", features = ["derive"] } +serde_json = "1.0.138" +tokio = { version = "1.43.0", features = ["full"] } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e75649c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM rust:1.83-slim-bullseye AS builder + +RUN apt-get update && apt-get install -y \ + build-essential \ + libssl-dev \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY Cargo.toml Cargo.lock ./ +COPY ./src ./src + +RUN cargo build --release && strip /app/target/release/imphnen-cms-api + +FROM gcr.io/distroless/cc AS runner + +WORKDIR /app + +COPY --from=builder /app/target/release/imphnen-cms-api . + +CMD ["/app/imphnen-cms-api"] diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..70b5415 --- /dev/null +++ b/default.nix @@ -0,0 +1,15 @@ +{pkgs ? import {}}: let + manifest = (pkgs.lib.importTOML ./Cargo.toml).package; + rustDeps = pkgs.callPackage ./Cargo.nix {}; + packageEntry = rustDeps.workspaceMembers.${manifest.name}; + deps = packageEntry.build.cargoDeps or null; +in + pkgs.rustPlatform.buildRustPackage { + pname = manifest.name; + version = manifest.version; + cargoDeps = deps; + src = pkgs.lib.cleanSource ./.; + cargoLock.lockFile = ./Cargo.lock; + nativeBuildInputs = [pkgs.openssl pkgs.pkg-config]; + buildInputs = [pkgs.openssl]; + } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..94dcfc8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + api: + build: + context: . + dockerfile: Dockerfile + ports: + - "${PORT}:${PORT}" + env_file: ".env" diff --git a/docker.nix b/docker.nix new file mode 100644 index 0000000..148e8f0 --- /dev/null +++ b/docker.nix @@ -0,0 +1,42 @@ +{pkgs, ...}: let + baseImage = pkgs.ociTools.pullImage { + imageName = "ubuntu"; + tag = "latest"; + }; +in + pkgs.dockerTools.buildImage { + name = "imphnen-cms-api"; + + fromImage = baseImage; + + copyToRoot = pkgs.buildEnv { + name = "imphnen-cms-api"; + paths = [ + (pkgs.stdenv.mkDerivation { + name = "imphnen-cms-api"; + src = ./src; + + buildInputs = [ + pkgs.rustc + pkgs.cargo + pkgs.openssl + pkgs.pkg-config + ]; + + buildPhase = '' + cargo build --release + ''; + + installPhase = '' + mkdir -p $out/bin + cp target/release/najm-course-api $out/bin/ + ''; + }) + ]; + }; + + config = { + Cmd = ["/bin/imphnen-cms-api"]; + WorkingDir = "/bin"; + }; + } diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..93310a8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "IMPHNEN CMS API Nix Flake"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + outputs = { + self, + nixpkgs, + }: let + supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = nixpkgs.legacyPackages; + in { + packages = forAllSystems (system: { + default = pkgsFor.${system}.callPackage ./default.nix {}; + }); + devShells = forAllSystems (system: { + default = pkgsFor.${system}.callPackage ./shell.nix {}; + }); + dockerImages = forAllSystems (system: { + tryOutApi = pkgsFor.${system}.callPackage ./docker.nix {}; + }); + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..1901d30 --- /dev/null +++ b/shell.nix @@ -0,0 +1,76 @@ +{pkgs ? import {}}: +pkgs.mkShell { + inputsFrom = [(pkgs.callPackage ./default.nix {})]; + buildInputs = with pkgs; [ + rust-analyzer + rustfmt + crate2nix + clippy + + (writeScriptBin "helpme" '' + __usage=" + 👋 Welcome to IMPHNEN CMS API development environment. 🚀 + If you see this message, it means your are inside the Nix shell ❄️. + + [Info]===============================================================> + + Rustc Version: v${rustc.version} + Rustup Version: v${rustup.version} + Cargo Version: v${cargo.version} + + Command available: + - start: start project in production 🛹 ( need to run build first ) + - build: build project for production + - dev: start project in development + - start-docker: start project in docker container ( compose ) + - build-docker: build project for docker container + - helpme: show this messages + + Repository: + - https://github.com/IMPHNEN/imphnen-cms-api + [Info]===============================================================> + " + echo "$__usage" + '') + + (writeScriptBin "dev" '' + cargo watch -x run + '') + + (writeScriptBin "start" '' + echo "Starting project in production mode..." + echo "Najm Course API started on port $PORT 🛹..." + ./result/bin/imphnen-cms-api + '') + + (writeScriptBin "build" '' + echo "Building project..." + crate2nix generate + nix build -f Cargo.nix + echo "Now you can start the project with the command 'start'" + '') + + (writeScriptBin "start-docker" '' + echo "Starting project in docker container..." + docker compose up -d + '') + + (writeScriptBin "build-docker" '' + echo "Building project with docker..." + docker build -t imphnen-api:latest . + echo "Project built successfully." + echo "Now you can start the project with the command 'start-docker'" + '') + ]; + + shellHook = '' + helpme + if [ -f .env ]; then + echo "Loading .env file..." + export $(cat .env | xargs) + echo "Successfully applied .env file." + else + echo ".env file not found." + fi + ''; +} diff --git a/src/apps/mod.rs b/src/apps/mod.rs new file mode 100644 index 0000000..ae6adc7 --- /dev/null +++ b/src/apps/mod.rs @@ -0,0 +1,2 @@ +pub mod v1; +pub mod v2; diff --git a/src/apps/v1/auth/auth_controller.rs b/src/apps/v1/auth/auth_controller.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v1/auth/auth_middleware.rs b/src/apps/v1/auth/auth_middleware.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v1/auth/auth_model.rs b/src/apps/v1/auth/auth_model.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v1/auth/auth_repository.rs b/src/apps/v1/auth/auth_repository.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v1/auth/mod.rs b/src/apps/v1/auth/mod.rs new file mode 100644 index 0000000..3c60469 --- /dev/null +++ b/src/apps/v1/auth/mod.rs @@ -0,0 +1,9 @@ +pub mod auth_controller; +pub mod auth_middleware; +pub mod auth_model; +pub mod auth_repository; + +pub use auth_controller::*; +pub use auth_middleware::*; +pub use auth_model::*; +pub use auth_repository::*; diff --git a/src/apps/v1/mod.rs b/src/apps/v1/mod.rs new file mode 100644 index 0000000..efadf86 --- /dev/null +++ b/src/apps/v1/mod.rs @@ -0,0 +1,3 @@ +pub mod auth; + +pub use auth::*; diff --git a/src/apps/v1/permissions/.gitkeep b/src/apps/v1/permissions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v1/roles/.gitkeep b/src/apps/v1/roles/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v1/users/.gitkeep b/src/apps/v1/users/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v2/.gitkeep b/src/apps/v2/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v2/auth/.gitkeep b/src/apps/v2/auth/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v2/mod.rs b/src/apps/v2/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v2/permissions/.gitkeep b/src/apps/v2/permissions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v2/roles/.gitkeep b/src/apps/v2/roles/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/v2/users/.gitkeep b/src/apps/v2/users/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..eb55244 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,9 @@ +pub mod apps; +pub mod libs; +pub mod utils; + +pub use apps::v1; +pub use apps::v2; + +pub use libs::axum; +pub use libs::seaorm; diff --git a/src/libs/axum/.gitkeep b/src/libs/axum/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/libs/axum/mod.rs b/src/libs/axum/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/libs/mod.rs b/src/libs/mod.rs new file mode 100644 index 0000000..ebbd9e6 --- /dev/null +++ b/src/libs/mod.rs @@ -0,0 +1,2 @@ +pub mod axum; +pub mod seaorm; diff --git a/src/libs/seaorm/.gitkeep b/src/libs/seaorm/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/libs/seaorm/mod.rs b/src/libs/seaorm/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs new file mode 100644 index 0000000..096b722 --- /dev/null +++ b/src/utils/mod.rs @@ -0,0 +1 @@ +pub mod password_hash; diff --git a/src/utils/password_hash.rs b/src/utils/password_hash.rs new file mode 100644 index 0000000..e69de29