Skip to content

Commit 1c25879

Browse files
committed
type fixes
1 parent 3b2e089 commit 1c25879

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

packages/express/src/client-requests/course-requests.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ import logger from '@/logger.js';
1010
import { CourseLookup } from '@vue-skuilder/db';
1111
import { courseDBDesignDocs } from '../design-docs.js';
1212

13-
/**
14-
* Fake fcn to allow usage in couchdb map fcns which, after passing
15-
* through `.toString()`, are applied to all courses
16-
*/
17-
function emit(key?: unknown, value?: unknown): [unknown, unknown] {
18-
return [key, value];
19-
}
20-
2113
function getCourseDBName(courseID: string): string {
2214
return `coursedb-${courseID}`;
2315
}
@@ -59,9 +51,6 @@ function insertDesignDoc(
5951
});
6052
}
6153

62-
63-
64-
6554
export async function initCourseDBDesignDocInsert(): Promise<void> {
6655
const courses = await CourseLookup.allCourses();
6756
courses.forEach((c) => {
@@ -71,7 +60,7 @@ export async function initCourseDBDesignDocInsert(): Promise<void> {
7160
});
7261

7362
// Update security object for public courses
74-
const courseDB = CouchDB.use(getCourseDBName(c._id));
63+
const courseDB = CouchDB.use<CourseConfig>(getCourseDBName(c._id));
7564
courseDB
7665
.get('CourseConfig')
7766
.then((configDoc) => {
@@ -87,6 +76,8 @@ export async function initCourseDBDesignDocInsert(): Promise<void> {
8776
},
8877
};
8978
courseDB
79+
// @ts-expect-error allow insertion of _security document.
80+
// db scoped as ConfigDoc to make the read easier.
9081
.insert(secObj as nano.MaybeDocument, '_security')
9182
.then(() => {
9283
logger.info(

packages/express/src/design-docs.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
import { CardData, DocType } from '@vue-skuilder/db';
12
import * as fileSystem from 'fs';
23

4+
/**
5+
* Fake fcn to allow usage in couchdb map fcns which, after passing
6+
* through `.toString()`, are applied to all courses
7+
*/
8+
function emit(key?: unknown, value?: unknown): [unknown, unknown] {
9+
return [key, value];
10+
}
11+
312
// Load design documents
413
export const classroomDbDesignDoc = fileSystem.readFileSync(
514
'./assets/classroomDesignDoc.js',
@@ -65,8 +74,9 @@ export const cardsByInexperienceDoc = {
6574
_id: '_design/cardsByInexperience',
6675
views: {
6776
cardsByInexperience: {
68-
map: function (doc) {
69-
if (doc.docType && doc.docType === 'CARD') {
77+
// eslint-disable-next-line
78+
map: function (doc: CardData) {
79+
if (doc.docType && doc.docType === DocType.CARD) {
7080
if (
7181
doc.elo &&
7282
doc.elo.global &&
@@ -94,5 +104,5 @@ export const courseDBDesignDocs = [
94104
elodoc,
95105
tagsDoc,
96106
cardsByInexperienceDoc,
97-
authDesignDoc
98-
];
107+
authDesignDoc,
108+
];

0 commit comments

Comments
 (0)