使用以下内容将路由应用于hapi。
如何重构export * from './foo';
,以每条路由的默认导出替换*
?
'use strict';
export * from './foo'; // This is the line I’m trying to refactor
'use strict';
import hapi from '@hapi/hapi';
const foo = [
{
method: 'POST',
path: '/v1/clients/me',
config: {
...
},
handler: async (request:hapi.Request, h:hapi.ResponseToolkit): Promise<hapi.ResponseObject> => {
...
}
},
];
export default foo;
这行得通,但要寻找单线。
'use strict';
import foo from './foo';
export const _foo = foo;
答案 0 :(得分:0)
只要写
class MyClass(object):
counter = 0
def __init__(self):
# other commands here
# update id
self.id = MyClass.counter
MyClass.counter += 1
a,b = MyClass(), MyClass()
print(a.id, b.id)
# 0 1
`