News server for metalamp internship.
- Download and install
stackas described here. - Clone this repository as described here or with
git clone https://github.com/alleksandrgall/MynewsServercommand if you havegitinstalled. stack setupfor downloading compiler,stack buildfor building app and downloading dependencies.- Make a
.cfgfile, or use the templateMynewsServer/config/config_template.cfg(there you can also find what can be configured). - Setup your local PostgreSQL database and copy a connection string to your config file.
- Provide a folder where images will be stored and put it's path to the config file.
- Populate server database by typing
stack run -- %YOUR_CONFIG_PATH% --migrate. - Run the server by typing
stack run %YOUR_CONFIG_PATH%
app/Main- Parses command arguments and runs server logic with production handlers.curl- Curl request for testing the serversrc/Handlers- Basic logic for the server, intoduces App monad, DB scheme and logger.src/Handlers/App- App monad (a wrapper over Servant Handler monad with access to DB, Logger, Image managment etc.src/Handlers/DB- DB scheme, DB handler (how to run Persistent eDSL), inital migration logicsrc/Handlers/Image- Logic of saving, deleting and getting an image from a local storage safely.src/Handlers/Katip- Wrapper around Katip environment used to implement KatipMiddleware for logging raw requests.
src/Config.hs- Parser for Configurator's config.src/App/Prod.hs- App implementation depending on Configurator's config.src/DB/Postgres.hs- DB implementation for PostgreSQL database.src/Image/File.hs- Image storage implementation for storing images in file system.src/Api- Server API implemented in Servanttest- Tests for application