first commit
This commit is contained in:
commit
5180c78e8f
47
.gitignore
vendored
Normal file
47
.gitignore
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
### Scala ###
|
||||||
|
.bsp/
|
||||||
5
.idea/.gitignore
generated
vendored
Normal file
5
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Environment-dependent path to Maven home directory
|
||||||
|
/mavenHomeManager.xml
|
||||||
7
.idea/codeStyles/Project.xml
generated
Normal file
7
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<ScalaCodeStyleSettings>
|
||||||
|
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||||
|
</ScalaCodeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
24
.idea/dataSources.local.xml
generated
Normal file
24
.idea/dataSources.local.xml
generated
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="dataSourceStorageLocal" created-in="IU-251.26927.53">
|
||||||
|
<data-source name="dev_yobble" uuid="8cc6eef6-a2cb-4f0d-8725-7254ac90d01a">
|
||||||
|
<database-info product="PostgreSQL" version="17.5 (Debian 17.5-1.pgdg120+1)" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.7.3" dbms="POSTGRES" exact-version="17.5" exact-driver-version="42.7">
|
||||||
|
<identifier-quote-string>"</identifier-quote-string>
|
||||||
|
</database-info>
|
||||||
|
<case-sensitivity plain-identifiers="lower" quoted-identifiers="exact" />
|
||||||
|
<secret-storage>master_key</secret-storage>
|
||||||
|
<user-name>yobble_app_user</user-name>
|
||||||
|
<schema-mapping>
|
||||||
|
<introspection-scope>
|
||||||
|
<node kind="database" qname="yobble_db">
|
||||||
|
<node kind="schema" qname="public" />
|
||||||
|
</node>
|
||||||
|
</introspection-scope>
|
||||||
|
</schema-mapping>
|
||||||
|
<ssh-properties>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<ssh-config-id>e7ab21f4-934a-4dec-b5f8-5504ead7fc52</ssh-config-id>
|
||||||
|
</ssh-properties>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
17
.idea/dataSources.xml
generated
Normal file
17
.idea/dataSources.xml
generated
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="dev_yobble" uuid="8cc6eef6-a2cb-4f0d-8725-7254ac90d01a">
|
||||||
|
<driver-ref>postgresql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:postgresql://localhost:5101/yobble_db</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8782
.idea/dataSources/8cc6eef6-a2cb-4f0d-8725-7254ac90d01a.xml
generated
Normal file
8782
.idea/dataSources/8cc6eef6-a2cb-4f0d-8725-7254ac90d01a.xml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
|||||||
|
#n:postgres
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#n:information_schema
|
||||||
|
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#n:pg_catalog
|
||||||
|
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#n:public
|
||||||
|
!<md> [810, 0, null, null, -2147483648, -2147483648]
|
||||||
@ -0,0 +1 @@
|
|||||||
|
#n:yobble_db
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#n:information_schema
|
||||||
|
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#n:pg_catalog
|
||||||
|
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#n:public
|
||||||
|
!<md> [816, 0, null, null, -2147483648, -2147483648]
|
||||||
Binary file not shown.
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="graalvm-jdk-21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
19
.idea/sbt.xml
generated
Normal file
19
.idea/sbt.xml
generated
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ScalaSbtSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<SbtProjectSettings>
|
||||||
|
<option name="converterVersion" value="2" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/project" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="sbtVersion" value="1.11.2" />
|
||||||
|
<option name="separateProdAndTestSourcesIsExplicit" value="true" />
|
||||||
|
</SbtProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/scala_compiler.xml
generated
Normal file
7
.idea/scala_compiler.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ScalaCompilerConfiguration">
|
||||||
|
<option name="separateProdTestSources" value="true" />
|
||||||
|
<profile name="sbt 1" modules="chat_private_service,chat_private_service.main,chat_private_service.test" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/scala_settings.xml
generated
Normal file
7
.idea/scala_settings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ScalaProjectSettings">
|
||||||
|
<option name="migrateConfigurationsNotificationShown" value="true" />
|
||||||
|
<option name="scala3DisclaimerShown" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
26
build.sbt
Normal file
26
build.sbt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
ThisBuild / version := "0.1.0-SNAPSHOT"
|
||||||
|
|
||||||
|
ThisBuild / scalaVersion := "3.3.6"
|
||||||
|
|
||||||
|
val catsVersion = "3.6.1"
|
||||||
|
val http4sVersion = "0.23.30"
|
||||||
|
val circeVersion = "0.14.8"
|
||||||
|
val tapirVersion = "1.11.35"
|
||||||
|
|
||||||
|
lazy val root = (project in file("."))
|
||||||
|
.settings(
|
||||||
|
name := "chat_private_service",
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"org.typelevel" %% "cats-effect" % catsVersion,
|
||||||
|
"org.http4s" %% "http4s-ember-server" % http4sVersion,
|
||||||
|
"org.http4s" %% "http4s-ember-client" % http4sVersion,
|
||||||
|
"org.http4s" %% "http4s-dsl" % http4sVersion,
|
||||||
|
"org.http4s" %% "http4s-circe" % http4sVersion,
|
||||||
|
"io.circe" %% "circe-generic" % circeVersion,
|
||||||
|
|
||||||
|
// Tapir + Swagger
|
||||||
|
"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % tapirVersion,
|
||||||
|
"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % tapirVersion,
|
||||||
|
"com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % tapirVersion
|
||||||
|
)
|
||||||
|
)
|
||||||
1
project/build.properties
Normal file
1
project/build.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
sbt.version = 1.11.2
|
||||||
32
src/main/scala/org/yobble/chat_private_service/Main.scala
Normal file
32
src/main/scala/org/yobble/chat_private_service/Main.scala
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package org.yobble.chat_private_service
|
||||||
|
|
||||||
|
import cats.effect.*
|
||||||
|
import io.circe.generic.auto.*
|
||||||
|
import org.http4s.*
|
||||||
|
import org.http4s.circe.*
|
||||||
|
import org.http4s.dsl.io.*
|
||||||
|
import org.http4s.ember.server.*
|
||||||
|
import org.http4s.implicits.*
|
||||||
|
import org.http4s.server.Router
|
||||||
|
|
||||||
|
import cats.implicits.toSemigroupKOps
|
||||||
|
import com.comcast.ip4s.{Port, host}
|
||||||
|
import org.http4s.circe.CirceEntityCodec.*
|
||||||
|
import org.yobble.chat_private_service.api.Routes
|
||||||
|
import org.yobble.chat_private_service.config.AppConfig
|
||||||
|
|
||||||
|
object Main extends IOApp {
|
||||||
|
override def run(args: List[String]): IO[ExitCode] =
|
||||||
|
EmberServerBuilder
|
||||||
|
.default[IO]
|
||||||
|
.withHost(host"0.0.0.0")
|
||||||
|
.withPort(port = Port.fromInt(AppConfig.PORT).get)
|
||||||
|
.withHttpApp(Routes.all.orNotFound)
|
||||||
|
.build
|
||||||
|
.use(_ =>
|
||||||
|
IO.println(s"Server running at http://${AppConfig.HOST}:${AppConfig.PORT}") *>
|
||||||
|
IO.println(s"Swagger UI available at http://${AppConfig.HOST}:${AppConfig.PORT}/docs") *>
|
||||||
|
IO.never
|
||||||
|
)
|
||||||
|
.as(ExitCode.Success)
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package org.yobble.chat_private_service.api
|
||||||
|
|
||||||
|
import cats.effect.IO
|
||||||
|
import org.http4s.HttpRoutes
|
||||||
|
import sttp.tapir.server.http4s._
|
||||||
|
import sttp.tapir.swagger.bundle.SwaggerInterpreter
|
||||||
|
import org.yobble.chat_private_service.api.endpoint.PingEndpoint._
|
||||||
|
import cats.syntax.semigroupk._
|
||||||
|
import org.yobble.chat_private_service.api.response.BaseResponse
|
||||||
|
|
||||||
|
object Routes {
|
||||||
|
private val pingRoute = Http4sServerInterpreter[IO]().toRoutes(
|
||||||
|
pingEndpoint.serverLogicSuccess(_ => IO.pure(BaseResponse("fine", "pong")))
|
||||||
|
)
|
||||||
|
|
||||||
|
private val docsRoutes = Http4sServerInterpreter[IO]().toRoutes(
|
||||||
|
SwaggerInterpreter().fromEndpoints[IO](
|
||||||
|
List(pingEndpoint),
|
||||||
|
"chat_private_service API",
|
||||||
|
"1.0"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val all: HttpRoutes[IO] = pingRoute <+> docsRoutes
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package org.yobble.chat_private_service.api.endpoint
|
||||||
|
|
||||||
|
import sttp.tapir._
|
||||||
|
import sttp.tapir.generic.auto._
|
||||||
|
import sttp.tapir.json.circe._
|
||||||
|
import io.circe.generic.auto._
|
||||||
|
import org.yobble.chat_private_service.api.response.BaseResponse
|
||||||
|
import org.yobble.chat_private_service.config.AppConfig
|
||||||
|
|
||||||
|
object PingEndpoint {
|
||||||
|
|
||||||
|
val pingEndpoint: PublicEndpoint[Unit, Unit, BaseResponse, Any] =
|
||||||
|
endpoint.get
|
||||||
|
.in("ping")
|
||||||
|
.out(jsonBody[BaseResponse])
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
package org.yobble.chat_private_service.api.response
|
||||||
|
|
||||||
|
final case class BaseResponse(status: String, message: String)
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package org.yobble.chat_private_service.config
|
||||||
|
|
||||||
|
object AppConfig {
|
||||||
|
|
||||||
|
val HOST = "0.0.0.0"
|
||||||
|
val PORT = 5205
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user