# dependency-for-microservice

> Notice that we have duplicated our models from the other services - this is bad, we have to extract the common code in to a npm module that we can then import in to our project just like any other package.

Latest version **1.0.4** (published 2020-03-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install dependency-for-microservice
pnpm add dependency-for-microservice
yarn add dependency-for-microservice
bun add dependency-for-microservice
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-03-06 |
| First published | 2020-03-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | rv8v |

## Links

- npm: https://www.npmjs.com/package/dependency-for-microservice
- npm.io page: https://npm.io/package/dependency-for-microservice

## Dependencies (1)

- [mongoose](https://npm.io/package/mongoose.md) ^5.9.3

## Recent versions

- 1.0.4 (latest) — 2020-03-06
- 1.0.3 — 2020-03-06
- 1.0.2 — 2020-03-06
- 1.0.1 — 2020-03-06
- 1.0.0 — 2020-03-06

## README

## Description
Notice that we have duplicated our models from the other services - this is bad, we have to extract the common code in to a npm module that we can then import in to our project just like any other package.  

The thing is that microservice search does not require its own database, it does not require its own model in like a very basic example - it does not need it. But what we do need - is to know how to basically get data from the database, we need to be able to need what the other services that we want to be able to search for. We need to have some type of connection.  
The idea is - have common code. If everythimg running on Node.js and we have things that need to be shared between different modules or different microservices. So that I put it in a npm package.  
That makes it very easy for us to move common code amongst our projects, we do not have to copy and paste duplicate.  
Because this is very dangerous - for example, I changed the book's module in my book's microservice, then I have to make sure that I'm changing it here /search/src/app.js as well. That's not so nice.

## Source Code
```javascript
'use strict'

const mongoose = require('mongoose')
const Schema = mongoose.Schema

const bookSchema = new Schema({
  name: String,
  type: { type: String, default: 'book' },
  createdAt: { type: Date, default: Date.now }
})

const videoSchema = new Schema({
  name: String,
  type: { type: String, default: 'video' },
  createdAt: { type: Date, default: Date.now }
});

module.exports = {
  Video: mongoose.model('Video', videoSchema),
  Book: mongoose.model('Book', bookSchema)
}
```

---
_Source: https://npm.io/package/dependency-for-microservice · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
