generated from trywilco/Anythink-Market-Public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WilcoApp
committed
Jan 22, 2024
1 parent
03873b9
commit 19b3370
Showing
171 changed files
with
7,332 additions
and
6,617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
.DS_Store | ||
|
||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
.gradle/ | ||
/build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
*.db | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
.nb-gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
FROM public.ecr.aws/v0a2l7y2/wilco/anythink-backend-node:latest | ||
FROM public.ecr.aws/v0a2l7y2/wilco/anythink-backend-java:latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
FROM node:16 | ||
FROM openjdk:11 | ||
|
||
WORKDIR /usr/src | ||
COPY backend ./backend | ||
COPY .wilco ./.wilco | ||
|
||
# Pre-install npm packages | ||
# Pre-install packages | ||
WORKDIR /usr/src/backend | ||
RUN yarn install | ||
|
||
RUN ./gradlew build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Aisensiy | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
# Anythink Market Backend | ||
|
||
The Anythink Market backend is Node web app written with [Express](https://expressjs.com/) | ||
# How it works | ||
|
||
## Dependencies | ||
The application uses Spring Boot (Web, Mybatis). | ||
|
||
- [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) - For generating JWTs used by authentication | ||
- [mongoose](https://github.com/Automattic/mongoose) - For modeling and mapping MongoDB data to javascript | ||
- [mongoose-unique-validator](https://github.com/blakehaswell/mongoose-unique-validator) - For handling unique validation errors in Mongoose. Mongoose only handles validation at the document level, so a unique index across a collection will throw an exception at the driver level. The `mongoose-unique-validator` plugin helps us by formatting the error like a normal mongoose `ValidationError`. | ||
- [passport](https://github.com/jaredhanson/passport) - For handling user authentication | ||
- [slug](https://github.com/dodo/node-slug) - For encoding titles into a URL-friendly format | ||
And the code is organized as this: | ||
|
||
## Application Structure | ||
1. `api` is the web layer implemented by Spring MVC | ||
2. `core` is the business model including entities and services | ||
3. `application` is the high-level services for querying the data transfer objects | ||
4. `infrastructure` contains all the implementation classes as the technique details | ||
|
||
- `app.js` - The entry point to our application. This file defines our express server and connects it to MongoDB using mongoose. It also requires the routes and models we'll be using in the application. | ||
- `config/` - This folder contains configuration for passport as well as a central location for configuration/environment variables. | ||
- `routes/` - This folder contains the route definitions for our API. | ||
- `models/` - This folder contains the schema definitions for our Mongoose models. | ||
# Getting started | ||
|
||
## Error Handling | ||
You'll need Java 11 installed. | ||
|
||
In `routes/api/index.js`, we define a error-handling middleware for handling Mongoose's `ValidationError`. This middleware will respond with a 422 status code and format the response to have [error messages the clients can understand](https://github.com/gothinkster/realworld/blob/master/API.md#errors-and-status-codes) | ||
./gradlew bootRun | ||
|
||
To test that it works, open a browser tab at http://localhost:3000/api/tags | ||
Alternatively, you can run: | ||
|
||
curl http://localhost:3000/api/tags | ||
|
||
# Run test | ||
|
||
The repository contains a lot of test cases to cover both api test and repository test. | ||
|
||
./gradlew test | ||
|
||
# Code format | ||
|
||
Use spotless for code format. | ||
|
||
./gradlew spotlessJavaApply |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
plugins { | ||
id 'org.springframework.boot' version '2.6.3' | ||
id 'io.spring.dependency-management' version '1.0.11.RELEASE' | ||
id 'java' | ||
id "com.netflix.dgs.codegen" version "5.0.6" | ||
id "com.diffplug.spotless" version "6.2.1" | ||
} | ||
|
||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '11' | ||
targetCompatibility = '11' | ||
|
||
spotless { | ||
java { | ||
target project.fileTree(project.rootDir) { | ||
include '**/*.java' | ||
exclude 'build/generated/**/*.*', 'build/generated-examples/**/*.*' | ||
} | ||
googleJavaFormat() | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
implementation 'org.springframework.boot:spring-boot-starter-hateoas' | ||
implementation 'org.springframework.boot:spring-boot-starter-security' | ||
implementation 'org.springframework.boot:spring-boot-starter-actuator' | ||
implementation 'org.springframework.boot:spring-boot-devtools' | ||
implementation 'com.squareup.okhttp3:okhttp:4.9.1' | ||
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2' | ||
implementation 'com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter:4.9.21' | ||
implementation 'org.flywaydb:flyway-core' | ||
implementation 'io.jsonwebtoken:jjwt-api:0.11.2' | ||
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2', | ||
'io.jsonwebtoken:jjwt-jackson:0.11.2' | ||
implementation 'joda-time:joda-time:2.10.13' | ||
implementation 'org.xerial:sqlite-jdbc:3.36.0.3' | ||
implementation 'org.postgresql:postgresql:42.2.24' | ||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0' | ||
|
||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
|
||
testImplementation 'io.rest-assured:rest-assured:4.5.1' | ||
testImplementation 'io.rest-assured:json-path:4.5.1' | ||
testImplementation 'io.rest-assured:xml-path:4.5.1' | ||
testImplementation 'io.rest-assured:spring-mock-mvc:4.5.1' | ||
testImplementation 'org.springframework.security:spring-security-test' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:2.2.2' | ||
testImplementation 'com.h2database:h2:1.4.200' | ||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
} | ||
|
||
tasks.named('clean') { | ||
doFirst { | ||
delete './dev.db' | ||
} | ||
} | ||
|
||
tasks.named('generateJava') { | ||
schemaPaths = ["${projectDir}/src/main/resources/schema"] // List of directories containing schema files | ||
packageName = 'io.spring.graphql' // The package name to use to generate sources | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.