-
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.
feat(mongoose): force
secondaryPreferred
if no secondaries in cluster
- Trigger early load of mongoose before any other import and implicit load of mongoose model - Add a global schema plugin that inspects schema for read preference - if `secondary`, check the cluster using mongoose connection - if cluster without secondaries, force read pref to be `secondaryPreferred`
- Loading branch information
Showing
2 changed files
with
59 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import './loaders/datadog-tracer' | ||
import './loaders/mongoose' | ||
|
||
import config from './config/config' | ||
import { createLoggerWithLabel } from './config/logger' | ||
import loadApp from './loaders' | ||
|
||
const logger = createLoggerWithLabel(module) | ||
|
||
const initServer = async () => { | ||
const app = await loadApp() | ||
|
||
// Configure aws-sdk based on environment | ||
// sdk is later used to upload images to S3 | ||
await config.configureAws() | ||
|
||
app.listen(config.port) | ||
|
||
logger.info({ | ||
message: `[${config.nodeEnv}] Connected to port ${config.port}`, | ||
meta: { | ||
action: 'initServer', | ||
}, | ||
}) | ||
} | ||
|
||
void initServer() |