@brimble/models 1.2.0-alpha.0 → 1.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 1.2.0-alpha.1 (2021-12-01)
7
+
8
+
9
+
10
+ # 1.2.0-alpha.0 (2021-09-17)
11
+
12
+
13
+ ### Features
14
+
15
+ * worked on getting branches of a repo ([916f023](https://github.com/brimblehq/brimble/commit/916f0239e09ec3dd46cb52c61672b508ce52e6ff)), closes [#7](https://github.com/brimblehq/brimble/issues/7)
16
+
17
+
18
+
19
+ # 1.1.0 (2021-09-05)
20
+
21
+
22
+ ### Features
23
+
24
+ * added models and worked on getting authenticated users ([8bfed20](https://github.com/brimblehq/brimble/commit/8bfed20803e3471dcfcab01398988a23ff0103a9))
25
+ * integrated github ([4f66b16](https://github.com/brimblehq/brimble/commit/4f66b165339382a303013bef7eda568e412e48d3))
26
+ * worked on getting and selecting repo ([bd38ade](https://github.com/brimblehq/brimble/commit/bd38ade7b2b8a374ae0293d840011d11ada99a5e))
27
+
28
+
29
+ ### Performance Improvements
30
+
31
+ * added logger ([3ae7966](https://github.com/brimblehq/brimble/commit/3ae7966c27667323bfdb2f8bb7ceeb6cd7cc373e))
32
+ * minor perf ([733bc61](https://github.com/brimblehq/brimble/commit/733bc61b0cc3ef2b7f85e7dfbd00243657f0a933))
33
+
34
+
35
+
36
+
37
+
6
38
  # 1.1.0 (2021-09-05)
7
39
 
8
40
 
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GIT_TYPE = void 0;
4
+ var GIT_TYPE;
5
+ (function (GIT_TYPE) {
6
+ GIT_TYPE["GITHUB"] = "GITHUB";
7
+ GIT_TYPE["GITLAB"] = "GITLAB";
8
+ GIT_TYPE["BITBUCKET"] = "BITBUCKET";
9
+ })(GIT_TYPE = exports.GIT_TYPE || (exports.GIT_TYPE = {}));
package/dist/index.js CHANGED
@@ -16,11 +16,11 @@ const dotenv_1 = __importDefault(require("dotenv"));
16
16
  const mongoose_1 = __importDefault(require("mongoose"));
17
17
  const utils_1 = require("@brimble/utils");
18
18
  // Connection to Mongo
19
- (() => __awaiter(void 0, void 0, void 0, function* () {
19
+ const connectToMongo = (mongoUrl) => __awaiter(void 0, void 0, void 0, function* () {
20
20
  dotenv_1.default.config();
21
- const mongoUrl = `${process.env.MONGODB_URI}`;
22
21
  const options = { useNewUrlParser: true, useUnifiedTopology: true };
23
22
  mongoose_1.default.set("useFindAndModify", false);
23
+ mongoose_1.default.set("useCreateIndex", true);
24
24
  try {
25
25
  yield mongoose_1.default.connect(mongoUrl, options);
26
26
  utils_1.log.info(`Database connection successful`);
@@ -29,8 +29,11 @@ const utils_1 = require("@brimble/utils");
29
29
  utils_1.log.error(`Error connecting to DB`, error);
30
30
  return process.exit(1);
31
31
  }
32
- }))();
32
+ });
33
+ exports.default = connectToMongo;
33
34
  var user_1 = require("./user");
34
35
  Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.default; } });
35
36
  var oauthUser_1 = require("./oauthUser");
36
37
  Object.defineProperty(exports, "OauthUser", { enumerable: true, get: function () { return oauthUser_1.default; } });
38
+ var project_1 = require("./project");
39
+ Object.defineProperty(exports, "Project", { enumerable: true, get: function () { return project_1.default; } });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mongoose_1 = require("mongoose");
4
+ const enum_1 = require("./enum");
5
+ const projectSchema = new mongoose_1.Schema({
6
+ user_id: {
7
+ type: mongoose_1.Schema.Types.ObjectId,
8
+ ref: "User",
9
+ required: true,
10
+ },
11
+ name: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ description: String,
16
+ type: {
17
+ type: enum_1.GIT_TYPE,
18
+ required: true,
19
+ },
20
+ private: {
21
+ type: Boolean,
22
+ required: true,
23
+ },
24
+ live: {
25
+ type: Boolean,
26
+ default: true,
27
+ },
28
+ stars: {
29
+ type: Number,
30
+ required: true,
31
+ default: 0,
32
+ },
33
+ }, { timestamps: true });
34
+ exports.default = mongoose_1.model("Project", projectSchema);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/enum/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export enum GIT_TYPE {
2
+ GITHUB = "GITHUB",
3
+ GITLAB = "GITLAB",
4
+ BITBUCKET = "BITBUCKET",
5
+ }
package/index.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import dotenv from "dotenv";
2
2
  import mongoose from "mongoose";
3
3
  import { log } from "@brimble/utils";
4
+
4
5
  // Connection to Mongo
5
- (async (): Promise<void> => {
6
+ const connectToMongo = async (mongoUrl: string): Promise<void> => {
6
7
  dotenv.config();
7
8
 
8
- const mongoUrl: string = `${process.env.MONGODB_URI}`;
9
9
  const options = { useNewUrlParser: true, useUnifiedTopology: true };
10
10
  mongoose.set("useFindAndModify", false);
11
+ mongoose.set("useCreateIndex", true);
12
+
11
13
  try {
12
14
  await mongoose.connect(mongoUrl, options);
13
15
  log.info(`Database connection successful`);
@@ -15,8 +17,10 @@ import { log } from "@brimble/utils";
15
17
  log.error(`Error connecting to DB`, error);
16
18
  return process.exit(1);
17
19
  }
18
- })();
20
+ };
19
21
 
22
+ export default connectToMongo;
20
23
  export { default as User } from "./user";
21
24
  export { default as OauthUser } from "./oauthUser";
22
- export { IUser, IOauthUser } from "./types";
25
+ export { default as Project } from "./project";
26
+ export { IUser, IOauthUser, IProject } from "./types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brimble/models",
3
- "version": "1.2.0-alpha.0",
3
+ "version": "1.2.0-alpha.1",
4
4
  "description": "Brimble models",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
package/project.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { model, Schema } from "mongoose";
2
+ import { GIT_TYPE } from "./enum";
3
+ import { IProject } from "./types";
4
+
5
+ const projectSchema: Schema = new Schema(
6
+ {
7
+ user_id: {
8
+ type: Schema.Types.ObjectId,
9
+ ref: "User",
10
+ required: true,
11
+ },
12
+ name: {
13
+ type: String,
14
+ required: true,
15
+ },
16
+ description: String,
17
+ type: {
18
+ type: GIT_TYPE,
19
+ required: true,
20
+ },
21
+ private: {
22
+ type: Boolean,
23
+ required: true,
24
+ },
25
+ live: {
26
+ type: Boolean,
27
+ default: true,
28
+ },
29
+ stars: {
30
+ type: Number,
31
+ required: true,
32
+ default: 0,
33
+ },
34
+ },
35
+ { timestamps: true }
36
+ );
37
+
38
+ export default model<IProject>("Project", projectSchema);
package/types/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { IUser } from "./user";
2
2
  export { IOauthUser } from "./oauthUser";
3
+ export { IProject } from "./project";
@@ -0,0 +1,11 @@
1
+ import { Document } from "mongoose";
2
+ import { GIT_TYPE } from "../enum";
3
+
4
+ export interface IProject extends Document {
5
+ name: string;
6
+ description?: string;
7
+ type: GIT_TYPE;
8
+ private: boolean;
9
+ live?: boolean;
10
+ stars: number;
11
+ }
package/.env DELETED
@@ -1 +0,0 @@
1
- MONGODB_URI=mongodb://localhost:27017/brimble