{"size": 969, "ext": "js", "max_stars_repo_path": "setup/server-initialisation.js", "max_stars_repo_name": "Thibtoy/Jean-Librairie-Back", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "setup/server-initialisation.js", "max_issues_repo_name": "Thibtoy/Jean-Librairie-Back", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "setup/server-initialisation.js", "max_forks_repo_name": "Thibtoy/Jean-Librairie-Back", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.5, "max_line_length": 96, "alphanum_fraction": 0.7605779154}
import express from 'express'
import bodyParser from 'body-parser'
import cookieParser from 'cookie-parser'
import morgan from 'morgan'
import router from './router'
import databaseInitialisation from './database-initialisation'

const initialisation = async server => {
	console.info('Initialising application backend')
	
	server.use(bodyParser.json())
	server.use(bodyParser.urlencoded({ extended: false }))

	server.use(cookieParser())

	server.use(morgan('tiny'))

	server.use(function (req, res, next) {
		res.setHeader('Access-Control-Allow-origin', 'http://localhost:1234')
		res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With, content-type, Authorization')
		res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE')
		res.setHeader("Access-Control-Allow-Credentials", true)
		next()
	})

	router(server)

	await databaseInitialisation()

	console.info('Application backend successfully initialised')
}

export default initialisation
