diff --git a/controllers/Default.js b/controllers/Default.js index 48dc3fa..4ccb114 100644 --- a/controllers/Default.js +++ b/controllers/Default.js @@ -1,9 +1,7 @@ -'use strict'; +import utils from '../utils/writer.js'; +import Service from '../service/DefaultService.js'; -const utils = require('../utils/writer.js'); -const Service = require('../service/DefaultService.js'); - -exports.resolve = function resolve (req, res) { +export const resolve = function resolve (req, res) { const identifier = req.params['identifier']; const accept = req.get('accept'); console.log('request: ' + identifier); diff --git a/index.cjs b/index.js similarity index 76% rename from index.cjs rename to index.js index 56718ee..f6b3596 100644 --- a/index.cjs +++ b/index.js @@ -1,8 +1,6 @@ -'use strict'; - -const http = require('http'); -const express = require('express'); -const Controller = require('./controllers/Default.js'); +import http from 'http'; +import express from 'express'; +import Controller from './controllers/Default.js'; const serverPort = 8080; diff --git a/package.json b/package.json index 16689d6..d453d4d 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,17 @@ "name": "uni-resolver-driver-did-key", "version": "0.5.0", "description": "Universal Resolver Driver", - "main": "index.cjs", + "main": "index.js", "scripts": { "prestart": "npm install", - "start": "node index.cjs" + "start": "node index.js" }, "keywords": [ "swagger" ], "license": "Unlicense", "private": true, - "type": "commonjs", + "type": "module", "dependencies": { "@malachit/did-key-jwk-jcs-pub": "0.3.0-unstable.12", "@transmute/did-key-bls12381": "0.3.0-unstable.10", diff --git a/service/DefaultService.js b/service/DefaultService.js index 5cd6aeb..1f1d5a4 100644 --- a/service/DefaultService.js +++ b/service/DefaultService.js @@ -1,6 +1,4 @@ -'use strict'; - -const didKey = require('@malachit/did-key.js'); +import didKey from '@malachit/did-key.js'; /** * Resolve a DID or other identifier. @@ -9,7 +7,7 @@ const didKey = require('@malachit/did-key.js'); * accept String The requested MIME type of the DID document or DID resolution result. (optional) * returns Object **/ -exports.resolve = function(identifier,accept) { +export const resolve = function(identifier,accept) { return new Promise(function(resolve, reject) { didKey.resolve(identifier) .then(function(didResolutionResult) { diff --git a/utils/writer.js b/utils/writer.js index 3cee5c6..ea4c0cd 100644 --- a/utils/writer.js +++ b/utils/writer.js @@ -3,11 +3,11 @@ var ResponsePayload = function(code, payload) { this.payload = payload; } -exports.respondWithCode = function(code, payload) { +export const respondWithCode = function(code, payload) { return new ResponsePayload(code, payload); } -var writeJson = exports.writeJson = function(response, arg1, arg2) { +export const writeJson = function(response, arg1, arg2) { var code; var payload;