mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-23 04:41:19 +00:00
Dessalines
8b88a8e75b
commitf5b75f342b
Merge:bd1fc2b
69389f6
Author: Dessalines <happydooby@gmail.com> Date: Thu Jan 23 19:17:42 2020 -0500 Done merging http-api and private_message commitbd1fc2b80b
Author: Dessalines <happydooby@gmail.com> Date: Thu Jan 23 16:46:07 2020 -0500 Remove danger from private-message.tsx commit69389f61c9
Author: Dessalines <happydooby@gmail.com> Date: Thu Jan 23 11:21:21 2020 -0500 Fixing http curl POST docs. commit7fdcae4f07
Merge:dbe9ad0
752318f
Author: Dessalines <happydooby@gmail.com> Date: Thu Jan 23 11:01:06 2020 -0500 Merge remote-tracking branch 'nutomic/http-api' into dessalines-http-api commit752318fdf3
Author: Felix <me@nutomic.com> Date: Thu Jan 23 15:22:17 2020 +0100 api fixes commit9ccff18f23
Author: Dessalines <happydooby@gmail.com> Date: Wed Jan 22 22:29:11 2020 -0500 Adding a toaster to replace alerts. Fixes #457 commit5197407dd2
Merge:bacb9ac
58f673a
Author: Dessalines <happydooby@gmail.com> Date: Wed Jan 22 21:20:38 2020 -0500 Merge branch 'private_messaging' into dev commit58f673ab78
Author: Dessalines <happydooby@gmail.com> Date: Wed Jan 22 21:09:17 2020 -0500 Adding message to comment node actions. commitbacb9ac59e
Merge:10c6505
7d3adda
Author: Dessalines <happydooby@gmail.com> Date: Wed Jan 22 20:37:08 2020 -0500 Merge branch 'private_messaging' into dev commit10c6505968
Author: Dessalines <happydooby@gmail.com> Date: Wed Jan 22 20:35:20 2020 -0500 Adding correct hello_name to mail. commit7d3adda0cd
Author: Dessalines <happydooby@gmail.com> Date: Wed Jan 22 16:35:29 2020 -0500 Adding private messaging, and matrix user ids. - Fixes #244 commitdbe9ad0998
Author: Dessalines <happydooby@gmail.com> Date: Mon Jan 20 18:49:54 2020 -0500 Fixing last. commit20c9c54806
Author: Dessalines <happydooby@gmail.com> Date: Sun Jan 19 13:31:37 2020 -0500 Updating API docs. commitdc84ccaac9
Merge:6c61dd2
3edd75e
Author: Dessalines <happydooby@gmail.com> Date: Sun Jan 19 10:06:25 2020 -0500 Merge branch 'master' into dessalines-http-api commit6c61dd266b
Merge:c5eecd0
e518954
Author: Dessalines <happydooby@gmail.com> Date: Sun Jan 19 09:09:00 2020 -0500 Merge remote-tracking branch 'nutomic/websocket-generics' into dessalines-http-api commite518954bca
Author: Felix <me@nutomic.com> Date: Sun Jan 19 14:25:50 2020 +0100 Use generics to reduce code duplication in websocket commitc5eecd055e
Author: Dessalines <happydooby@gmail.com> Date: Sun Jan 19 00:38:45 2020 -0500 Strongly typing WebsocketJsonResponse. Forgot comment-form.tsx commit0c5eb47135
Author: Dessalines <happydooby@gmail.com> Date: Sat Jan 18 23:54:10 2020 -0500 First pass at fixing UI to work with new websocketresponses. commitbaf77bb6be
Author: Felix <me@nutomic.com> Date: Sat Jan 18 17:25:45 2020 +0100 simplify json serialization code commit047ec97e18
Author: Felix <me@nutomic.com> Date: Sat Jan 18 14:22:25 2020 +0100 rewrite api endpoint urls commit2fb4900b0c
Author: Felix <me@nutomic.com> Date: Thu Jan 16 17:04:37 2020 +0100 fix typo commitcba8081579
Author: Felix <me@nutomic.com> Date: Thu Jan 16 16:47:38 2020 +0100 fix formatting commitd7285d8c25
Author: Felix <me@nutomic.com> Date: Thu Jan 16 16:09:01 2020 +0100 small fix commit415040a1e9
Author: Felix <me@nutomic.com> Date: Thu Jan 16 15:39:08 2020 +0100 working! commit7a97c981a0
Author: Felix <me@nutomic.com> Date: Wed Jan 15 16:48:21 2020 +0100 try to simplify code with higher order functions commitc41082f98f
Author: Felix <me@nutomic.com> Date: Wed Jan 15 16:37:25 2020 +0100 Implement HTTP API using generics (fixes #380)
67 lines
1.8 KiB
Rust
67 lines
1.8 KiB
Rust
extern crate lemmy_server;
|
|
#[macro_use]
|
|
extern crate diesel_migrations;
|
|
|
|
use actix::prelude::*;
|
|
use actix_web::*;
|
|
use diesel::r2d2::{ConnectionManager, Pool};
|
|
use diesel::PgConnection;
|
|
use lemmy_server::routes::{api, federation, feeds, index, nodeinfo, webfinger, websocket};
|
|
use lemmy_server::settings::Settings;
|
|
use lemmy_server::websocket::server::*;
|
|
use std::io;
|
|
|
|
embed_migrations!();
|
|
|
|
#[actix_rt::main]
|
|
async fn main() -> io::Result<()> {
|
|
env_logger::init();
|
|
let settings = Settings::get();
|
|
|
|
// Set up the r2d2 connection pool
|
|
let manager = ConnectionManager::<PgConnection>::new(&settings.get_database_url());
|
|
let pool = Pool::builder()
|
|
.max_size(settings.database.pool_size)
|
|
.build(manager)
|
|
.unwrap_or_else(|_| panic!("Error connecting to {}", settings.get_database_url()));
|
|
|
|
// Run the migrations from code
|
|
let conn = pool.get().unwrap();
|
|
embedded_migrations::run(&conn).unwrap();
|
|
|
|
// Set up websocket server
|
|
let server = ChatServer::startup(pool.clone()).start();
|
|
|
|
println!(
|
|
"Starting http server at {}:{}",
|
|
settings.bind, settings.port
|
|
);
|
|
|
|
// Create Http server with websocket support
|
|
HttpServer::new(move || {
|
|
App::new()
|
|
.wrap(middleware::Logger::default())
|
|
.data(pool.clone())
|
|
.data(server.clone())
|
|
// The routes
|
|
.configure(api::config)
|
|
.configure(federation::config)
|
|
.configure(feeds::config)
|
|
.configure(index::config)
|
|
.configure(nodeinfo::config)
|
|
.configure(webfinger::config)
|
|
.configure(websocket::config)
|
|
// static files
|
|
.service(actix_files::Files::new(
|
|
"/static",
|
|
settings.front_end_dir.to_owned(),
|
|
))
|
|
.service(actix_files::Files::new(
|
|
"/docs",
|
|
settings.front_end_dir.to_owned() + "/documentation",
|
|
))
|
|
})
|
|
.bind((settings.bind, settings.port))?
|
|
.run()
|
|
.await
|
|
}
|